Changeset 751 for trunk/server/source3/lib/pthreadpool
- Timestamp:
- Nov 29, 2012, 1:59:04 PM (13 years ago)
- Location:
- trunk/server/source3/lib/pthreadpool
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server/source3/lib/pthreadpool/pthreadpool.c
r745 r751 288 288 */ 289 289 290 int pthreadpool_finished_job(struct pthreadpool *pool )291 { 292 int re sult;290 int pthreadpool_finished_job(struct pthreadpool *pool, int *jobid) 291 { 292 int ret_jobid; 293 293 ssize_t nread; 294 294 … … 297 297 298 298 while ((nread == -1) && (errno == EINTR)) { 299 nread = read(pool->sig_pipe[0], &re sult, sizeof(int));299 nread = read(pool->sig_pipe[0], &ret_jobid, sizeof(int)); 300 300 } 301 301 if (nread == -1) { … … 305 305 return EINVAL; 306 306 } 307 return result; 307 *jobid = ret_jobid; 308 return 0; 308 309 } 309 310 -
trunk/server/source3/lib/pthreadpool/pthreadpool.h
r745 r751 91 91 * 92 92 * @param[in] pool The pool to query for finished jobs 93 * @return The job_id of the finished job 93 * @param[out] pjobid The job_id of the finished job 94 * @return success: 0, failure: errno 94 95 */ 95 int pthreadpool_finished_job(struct pthreadpool *pool );96 int pthreadpool_finished_job(struct pthreadpool *pool, int *jobid); 96 97 97 98 #endif -
trunk/server/source3/lib/pthreadpool/tests.c
r745 r751 69 69 70 70 for (i=0; i<num_jobs; i++) { 71 ret = pthreadpool_finished_job(p); 72 if ((ret < 0) || (ret >= num_jobs)) { 73 fprintf(stderr, "invalid job number %d\n", ret); 74 return -1; 75 } 76 finished[ret] += 1; 71 int jobid = -1; 72 ret = pthreadpool_finished_job(p, &jobid); 73 if ((ret != 0) || (jobid >= num_jobs)) { 74 fprintf(stderr, "invalid job number %d\n", jobid); 75 return -1; 76 } 77 finished[jobid] += 1; 77 78 } 78 79 … … 276 277 277 278 for (j=0; j<num_pools; j++) { 279 int jobid = -1; 278 280 279 281 if ((pfds[j].revents & (POLLIN|POLLHUP)) == 0) { … … 281 283 } 282 284 283 ret = pthreadpool_finished_job(pools[j] );284 if ((ret < 0) || (ret>= num_jobs * num_threads)) {285 ret = pthreadpool_finished_job(pools[j], &jobid); 286 if ((ret != 0) || (jobid >= num_jobs * num_threads)) { 285 287 fprintf(stderr, "invalid job number %d\n", 286 ret);288 jobid); 287 289 return -1; 288 290 } 289 finished[ ret] += 1;291 finished[jobid] += 1; 290 292 received += 1; 291 293 }
Note:
See TracChangeset
for help on using the changeset viewer.