The branch, master has been updated
       via  711c18c Change the signature of pthreadpool_finished_job() to 
return 0 on success, errno on fail and return the jobid in a separate variable.
      from  8303d16 param: domain_logons and domain_master are of type 
enum_bool_auto

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 711c18c2301d1bea35cac1144080a94e6b89be27
Author: Jeremy Allison <[email protected]>
Date:   Wed Dec 21 20:38:32 2011 -0800

    Change the signature of pthreadpool_finished_job() to return 0
    on success, errno on fail and return the jobid in a separate variable.
    
    I need this fix for my vfs_aio_pthread.c module.
    
    Autobuild-User: Jeremy Allison <[email protected]>
    Autobuild-Date: Thu Dec 22 12:12:33 CET 2011 on sn-devel-104

-----------------------------------------------------------------------

Summary of changes:
 source3/lib/fncall.c                  |    3 +--
 source3/lib/pthreadpool/pthreadpool.c |    9 +++++----
 source3/lib/pthreadpool/pthreadpool.h |    5 +++--
 source3/lib/pthreadpool/tests.c       |   18 ++++++++++--------
 4 files changed, 19 insertions(+), 16 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/lib/fncall.c b/source3/lib/fncall.c
index 6e6b7c9..79bf826 100644
--- a/source3/lib/fncall.c
+++ b/source3/lib/fncall.c
@@ -280,8 +280,7 @@ static void fncall_handler(struct tevent_context *ev, 
struct tevent_fd *fde,
        int i, num_pending;
        int job_id;
 
-       job_id = pthreadpool_finished_job(ctx->pool);
-       if (job_id <= 0) {
+       if (pthreadpool_finished_job(ctx->pool, &job_id) != 0) {
                return;
        }
 
diff --git a/source3/lib/pthreadpool/pthreadpool.c 
b/source3/lib/pthreadpool/pthreadpool.c
index c916dc0..fffbd05 100644
--- a/source3/lib/pthreadpool/pthreadpool.c
+++ b/source3/lib/pthreadpool/pthreadpool.c
@@ -285,16 +285,16 @@ 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 pthreadpool_finished_job(struct pthreadpool *pool, int *jobid)
 {
-       int result;
+       int ret_jobid;
        ssize_t nread;
 
        nread = -1;
        errno = EINTR;
 
        while ((nread == -1) && (errno == EINTR)) {
-               nread = read(pool->sig_pipe[0], &result, sizeof(int));
+               nread = read(pool->sig_pipe[0], &ret_jobid, sizeof(int));
        }
        if (nread == -1) {
                return errno;
@@ -302,7 +302,8 @@ int pthreadpool_finished_job(struct pthreadpool *pool)
        if (nread != sizeof(int)) {
                return EINVAL;
        }
-       return result;
+       *jobid = ret_jobid;
+       return 0;
 }
 
 /*
diff --git a/source3/lib/pthreadpool/pthreadpool.h 
b/source3/lib/pthreadpool/pthreadpool.h
index 79704ea..0fde3c8 100644
--- a/source3/lib/pthreadpool/pthreadpool.h
+++ b/source3/lib/pthreadpool/pthreadpool.h
@@ -90,8 +90,9 @@ int pthreadpool_signal_fd(struct pthreadpool *pool);
  * pthreadpool_signal_fd() is readable.
  *
  * @param[in]  pool            The pool to query for finished jobs
- * @return                     The job_id of the finished job
+ * @param[out]  pjobid         The job_id of the finished job
+ * @return                     success: 0, failure: errno
  */
-int pthreadpool_finished_job(struct pthreadpool *pool);
+int pthreadpool_finished_job(struct pthreadpool *pool, int *jobid);
 
 #endif
diff --git a/source3/lib/pthreadpool/tests.c b/source3/lib/pthreadpool/tests.c
index 667ee01..95d37b6 100644
--- a/source3/lib/pthreadpool/tests.c
+++ b/source3/lib/pthreadpool/tests.c
@@ -68,12 +68,13 @@ static int test_jobs(int num_threads, int num_jobs)
        }
 
        for (i=0; i<num_jobs; i++) {
-               ret = pthreadpool_finished_job(p);
-               if ((ret < 0) || (ret >= num_jobs)) {
-                       fprintf(stderr, "invalid job number %d\n", ret);
+               int jobid = -1;
+               ret = pthreadpool_finished_job(p, &jobid);
+               if ((ret != 0) || (jobid >= num_jobs)) {
+                       fprintf(stderr, "invalid job number %d\n", jobid);
                        return -1;
                }
-               finished[ret] += 1;
+               finished[jobid] += 1;
        }
 
        for (i=0; i<num_jobs; i++) {
@@ -275,18 +276,19 @@ static int test_threaded_addjob(int num_pools, int 
num_threads, int poolsize,
                }
 
                for (j=0; j<num_pools; j++) {
+                       int jobid = -1;
 
                        if ((pfds[j].revents & (POLLIN|POLLHUP)) == 0) {
                                continue;
                        }
 
-                       ret = pthreadpool_finished_job(pools[j]);
-                       if ((ret < 0) || (ret >= num_jobs * num_threads)) {
+                       ret = pthreadpool_finished_job(pools[j], &jobid);
+                       if ((ret != 0) || (jobid >= num_jobs * num_threads)) {
                                fprintf(stderr, "invalid job number %d\n",
-                                       ret);
+                                       jobid);
                                return -1;
                        }
-                       finished[ret] += 1;
+                       finished[jobid] += 1;
                        received += 1;
                }
        }


-- 
Samba Shared Repository

Reply via email to