summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2016-07-31 08:57:35 +0200
committerJeremy Allison <jra@samba.org>2016-08-24 01:33:48 +0200
commitd7e51286e7ab08f3b5f5ba243b3b88e23f3fe360 (patch)
treead90085cf6526cce29bb74b40ccae882919da96f /source3/lib
parent5593467eb1a838ac542fa0fca6a5e2b989bbde31 (diff)
downloadsamba-d7e51286e7ab08f3b5f5ba243b3b88e23f3fe360.tar.gz
lib: add job data to to callback
The pthreadpool_tevent wrapper will need this Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/pthreadpool/pthreadpool.c19
-rw-r--r--source3/lib/pthreadpool/pthreadpool.h7
-rw-r--r--source3/lib/pthreadpool/pthreadpool_pipe.c10
-rw-r--r--source3/lib/pthreadpool/pthreadpool_sync.c13
4 files changed, 35 insertions, 14 deletions
diff --git a/source3/lib/pthreadpool/pthreadpool.c b/source3/lib/pthreadpool/pthreadpool.c
index 4c2858a0dee..fc21d43e1a4 100644
--- a/source3/lib/pthreadpool/pthreadpool.c
+++ b/source3/lib/pthreadpool/pthreadpool.c
@@ -59,8 +59,11 @@ struct pthreadpool {
/*
* Indicate job completion
*/
- int (*signal_fn)(int jobid, void *private_data);
- void *signal_private_data;
+ int (*signal_fn)(int jobid,
+ void (*job_fn)(void *private_data),
+ void *job_fn_private_data,
+ void *private_data);
+ void *signal_fn_private_data;
/*
* indicator to worker threads that they should shut down
@@ -100,8 +103,11 @@ static void pthreadpool_prep_atfork(void);
*/
int pthreadpool_init(unsigned max_threads, struct pthreadpool **presult,
- int (*signal_fn)(int jobid, void *private_data),
- void *signal_private_data)
+ int (*signal_fn)(int jobid,
+ void (*job_fn)(void *private_data),
+ void *job_fn_private_data,
+ void *private_data),
+ void *signal_fn_private_data)
{
struct pthreadpool *pool;
int ret;
@@ -111,7 +117,7 @@ int pthreadpool_init(unsigned max_threads, struct pthreadpool **presult,
return ENOMEM;
}
pool->signal_fn = signal_fn;
- pool->signal_private_data = signal_private_data;
+ pool->signal_fn_private_data = signal_fn_private_data;
pool->jobs_array_len = 4;
pool->jobs = calloc(
@@ -484,7 +490,8 @@ static void *pthreadpool_server(void *arg)
assert(res == 0);
ret = pool->signal_fn(job.id,
- pool->signal_private_data);
+ job.fn, job.private_data,
+ pool->signal_fn_private_data);
if (ret != 0) {
pthreadpool_server_exit(pool);
pthread_mutex_unlock(&pool->mutex);
diff --git a/source3/lib/pthreadpool/pthreadpool.h b/source3/lib/pthreadpool/pthreadpool.h
index 0b8d6e590c8..ee9d9578050 100644
--- a/source3/lib/pthreadpool/pthreadpool.h
+++ b/source3/lib/pthreadpool/pthreadpool.h
@@ -44,8 +44,11 @@ struct pthreadpool;
* care to not overload the system.
*/
int pthreadpool_init(unsigned max_threads, struct pthreadpool **presult,
- int (*signal_fn)(int jobid, void *private_data),
- void *signal_private_data);
+ int (*signal_fn)(int jobid,
+ void (*job_fn)(void *private_data),
+ void *job_fn_private_data,
+ void *private_data),
+ void *signal_fn_private_data);
/**
* @brief Destroy a pthreadpool
diff --git a/source3/lib/pthreadpool/pthreadpool_pipe.c b/source3/lib/pthreadpool/pthreadpool_pipe.c
index 3eaf5e39bd9..f7995abb140 100644
--- a/source3/lib/pthreadpool/pthreadpool_pipe.c
+++ b/source3/lib/pthreadpool/pthreadpool_pipe.c
@@ -28,7 +28,10 @@ struct pthreadpool_pipe {
int pipe_fds[2];
};
-static int pthreadpool_pipe_signal(int jobid, void *private_data);
+static int pthreadpool_pipe_signal(int jobid,
+ void (*job_fn)(void *private_data),
+ void *job_private_data,
+ void *private_data);
int pthreadpool_pipe_init(unsigned max_threads,
struct pthreadpool_pipe **presult)
@@ -62,7 +65,10 @@ int pthreadpool_pipe_init(unsigned max_threads,
return 0;
}
-static int pthreadpool_pipe_signal(int jobid, void *private_data)
+static int pthreadpool_pipe_signal(int jobid,
+ void (*job_fn)(void *private_data),
+ void *job_private_data,
+ void *private_data)
{
struct pthreadpool_pipe *pool = private_data;
ssize_t written;
diff --git a/source3/lib/pthreadpool/pthreadpool_sync.c b/source3/lib/pthreadpool/pthreadpool_sync.c
index 3e78f467179..d9a95f53c61 100644
--- a/source3/lib/pthreadpool/pthreadpool_sync.c
+++ b/source3/lib/pthreadpool/pthreadpool_sync.c
@@ -26,14 +26,18 @@ struct pthreadpool {
* Indicate job completion
*/
int (*signal_fn)(int jobid,
+ void (*job_fn)(void *private_data),
+ void *job_fn_private_data,
void *private_data);
- void *signal_private_data;
+ void *signal_fn_private_data;
};
int pthreadpool_init(unsigned max_threads, struct pthreadpool **presult,
int (*signal_fn)(int jobid,
+ void (*job_fn)(void *private_data),
+ void *job_fn_private_data,
void *private_data),
- void *signal_private_data)
+ void *signal_fn_private_data)
{
struct pthreadpool *pool;
@@ -42,7 +46,7 @@ int pthreadpool_init(unsigned max_threads, struct pthreadpool **presult,
return ENOMEM;
}
pool->signal_fn = signal_fn;
- pool->signal_private_data = signal_private_data;
+ pool->signal_fn_private_data = signal_fn_private_data;
*presult = pool;
return 0;
@@ -53,7 +57,8 @@ int pthreadpool_add_job(struct pthreadpool *pool, int job_id,
{
fn(private_data);
- return pool->signal_fn(job_id, pool->signal_private_data);
+ return pool->signal_fn(job_id, fn, private_data,
+ pool->signal_fn_private_data);
}
int pthreadpool_destroy(struct pthreadpool *pool)