diff options
author | Volker Lendecke <vl@samba.org> | 2014-03-24 10:39:56 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2014-03-27 06:06:11 +0100 |
commit | c5d07df6abe657ff196266bbfbb376ca7db0968b (patch) | |
tree | 926b6cf1b9444e90aa8e17f0c09d7a8df2a3433d /source3/lib/pthreadpool/pthreadpool.c | |
parent | 84aa2ddd861549d6ec8d1ef15f4fd518e03f449b (diff) | |
download | samba-c5d07df6abe657ff196266bbfbb376ca7db0968b.tar.gz samba-c5d07df6abe657ff196266bbfbb376ca7db0968b.tar.xz samba-c5d07df6abe657ff196266bbfbb376ca7db0968b.zip |
pthreadpool: Allow multiple jobs to be received
This can avoid syscalls when multiple jobs are finished simultaneously
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/lib/pthreadpool/pthreadpool.c')
-rw-r--r-- | source3/lib/pthreadpool/pthreadpool.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/source3/lib/pthreadpool/pthreadpool.c b/source3/lib/pthreadpool/pthreadpool.c index d51e808360..4436ab3289 100644 --- a/source3/lib/pthreadpool/pthreadpool.c +++ b/source3/lib/pthreadpool/pthreadpool.c @@ -288,25 +288,26 @@ static void pthreadpool_join_children(struct pthreadpool *pool) * Fetch a finished job number from the signal pipe */ -int pthreadpool_finished_job(struct pthreadpool *pool, int *jobid) +int pthreadpool_finished_jobs(struct pthreadpool *pool, int *jobids, + unsigned num_jobids) { - int ret_jobid; - ssize_t nread; + ssize_t to_read, nread; nread = -1; errno = EINTR; + to_read = sizeof(int) * num_jobids; + while ((nread == -1) && (errno == EINTR)) { - nread = read(pool->sig_pipe[0], &ret_jobid, sizeof(int)); + nread = read(pool->sig_pipe[0], jobids, to_read); } if (nread == -1) { - return errno; + return -errno; } - if (nread != sizeof(int)) { - return EINVAL; + if ((nread % sizeof(int)) != 0) { + return -EINVAL; } - *jobid = ret_jobid; - return 0; + return nread / sizeof(int); } /* |