Ignore:
Timestamp:
Nov 24, 2016, 1:14:11 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/lib/fncall.c

    r746 r988  
    2121#include "../lib/util/tevent_unix.h"
    2222
    23 #if WITH_PTHREADPOOL
    24 
    2523#include "lib/pthreadpool/pthreadpool.h"
    2624
     
    4341        int num_orphaned;
    4442
    45         struct fd_event *fde;
     43        struct tevent_fd *fde;
    4644};
    4745
     
    125123
    126124static void fncall_unset_pending(struct tevent_req *req);
    127 static int fncall_destructor(struct tevent_req *req);
     125static void fncall_cleanup(struct tevent_req *req,
     126                           enum tevent_req_state req_state);
    128127
    129128static bool fncall_set_pending(struct tevent_req *req,
     
    144143        num_pending += 1;
    145144        ctx->pending = pending;
    146         talloc_set_destructor(req, fncall_destructor);
     145        tevent_req_set_cleanup_fn(req, fncall_cleanup);
    147146
    148147        /*
    149148         * Make sure that the orphaned array of fncall_state structs has
    150149         * enough space. A job can change from pending to orphaned in
    151          * fncall_destructor, and to fail in a talloc destructor should be
     150         * fncall_cleanup, and to fail in a talloc destructor should be
    152151         * avoided if possible.
    153152         */
     
    187186        int i;
    188187
     188        tevent_req_set_cleanup_fn(req, NULL);
     189
    189190        if (num_pending == 1) {
    190191                TALLOC_FREE(ctx->fde);
     
    208209}
    209210
    210 static int fncall_destructor(struct tevent_req *req)
     211static void fncall_cleanup(struct tevent_req *req,
     212                           enum tevent_req_state req_state)
    211213{
    212214        struct fncall_state *state = tevent_req_data(
     
    214216        struct fncall_context *ctx = state->ctx;
    215217
     218        switch (req_state) {
     219        case TEVENT_REQ_RECEIVED:
     220                break;
     221        default:
     222                return;
     223        }
     224
    216225        fncall_unset_pending(req);
    217226
    218227        if (state->done) {
    219                 return 0;
     228                return;
    220229        }
    221230
     
    226235        ctx->orphaned[ctx->num_orphaned] = talloc_move(ctx->orphaned, &state);
    227236        ctx->num_orphaned += 1;
    228 
    229         return 0;
    230237}
    231238
     
    267274        }
    268275        if (!fncall_set_pending(req, state->ctx, ev)) {
    269                 tevent_req_nomem(NULL, req);
     276                tevent_req_oom(req);
    270277                return tevent_req_post(req, ev);
    271278        }
     
    281288        int job_id;
    282289
    283         if (pthreadpool_finished_job(ctx->pool, &job_id) != 0) {
     290        if (pthreadpool_finished_jobs(ctx->pool, &job_id, 1) < 0) {
    284291                return;
    285292        }
     
    324331        return 0;
    325332}
    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.