Changeset 988 for vendor/current/source3/lib/fncall.c
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/lib/fncall.c
r746 r988 21 21 #include "../lib/util/tevent_unix.h" 22 22 23 #if WITH_PTHREADPOOL24 25 23 #include "lib/pthreadpool/pthreadpool.h" 26 24 … … 43 41 int num_orphaned; 44 42 45 struct fd_event*fde;43 struct tevent_fd *fde; 46 44 }; 47 45 … … 125 123 126 124 static void fncall_unset_pending(struct tevent_req *req); 127 static int fncall_destructor(struct tevent_req *req); 125 static void fncall_cleanup(struct tevent_req *req, 126 enum tevent_req_state req_state); 128 127 129 128 static bool fncall_set_pending(struct tevent_req *req, … … 144 143 num_pending += 1; 145 144 ctx->pending = pending; 146 t alloc_set_destructor(req, fncall_destructor);145 tevent_req_set_cleanup_fn(req, fncall_cleanup); 147 146 148 147 /* 149 148 * Make sure that the orphaned array of fncall_state structs has 150 149 * enough space. A job can change from pending to orphaned in 151 * fncall_ destructor, and to fail in a talloc destructor should be150 * fncall_cleanup, and to fail in a talloc destructor should be 152 151 * avoided if possible. 153 152 */ … … 187 186 int i; 188 187 188 tevent_req_set_cleanup_fn(req, NULL); 189 189 190 if (num_pending == 1) { 190 191 TALLOC_FREE(ctx->fde); … … 208 209 } 209 210 210 static int fncall_destructor(struct tevent_req *req) 211 static void fncall_cleanup(struct tevent_req *req, 212 enum tevent_req_state req_state) 211 213 { 212 214 struct fncall_state *state = tevent_req_data( … … 214 216 struct fncall_context *ctx = state->ctx; 215 217 218 switch (req_state) { 219 case TEVENT_REQ_RECEIVED: 220 break; 221 default: 222 return; 223 } 224 216 225 fncall_unset_pending(req); 217 226 218 227 if (state->done) { 219 return 0;228 return; 220 229 } 221 230 … … 226 235 ctx->orphaned[ctx->num_orphaned] = talloc_move(ctx->orphaned, &state); 227 236 ctx->num_orphaned += 1; 228 229 return 0;230 237 } 231 238 … … 267 274 } 268 275 if (!fncall_set_pending(req, state->ctx, ev)) { 269 tevent_req_ nomem(NULL,req);276 tevent_req_oom(req); 270 277 return tevent_req_post(req, ev); 271 278 } … … 281 288 int job_id; 282 289 283 if (pthreadpool_finished_job (ctx->pool, &job_id) !=0) {290 if (pthreadpool_finished_jobs(ctx->pool, &job_id, 1) < 0) { 284 291 return; 285 292 } … … 324 331 return 0; 325 332 } 326 327 #else /* WITH_PTHREADPOOL */328 329 struct fncall_context {330 uint8_t dummy;331 };332 333 struct fncall_context *fncall_context_init(TALLOC_CTX *mem_ctx,334 int max_threads)335 {336 return talloc(mem_ctx, struct fncall_context);337 }338 339 struct fncall_state {340 uint8_t dummy;341 };342 343 struct tevent_req *fncall_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,344 struct fncall_context *ctx,345 void (*fn)(void *private_data),346 void *private_data)347 {348 struct tevent_req *req;349 struct fncall_state *state;350 351 req = tevent_req_create(mem_ctx, &state, struct fncall_state);352 if (req == NULL) {353 return NULL;354 }355 fn(private_data);356 tevent_req_post(req, ev);357 return req;358 }359 360 int fncall_recv(struct tevent_req *req, int *perr)361 {362 return 0;363 }364 365 #endif
Note:
See TracChangeset
for help on using the changeset viewer.