Ignore:
Timestamp:
Nov 25, 2016, 8:04:54 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.7

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/ctdb/server/eventscript.c

    r988 r989  
    697697{
    698698        DLIST_REMOVE(callback->ctdb->script_callbacks, callback);
     699        return 0;
     700}
     701
     702struct schedule_callback_state {
     703        struct ctdb_context *ctdb;
     704        void (*callback)(struct ctdb_context *, int, void *);
     705        void *private_data;
     706        int status;
     707        struct tevent_immediate *im;
     708};
     709
     710static void schedule_callback_handler(struct tevent_context *ctx,
     711                                      struct tevent_immediate *im,
     712                                      void *private_data)
     713{
     714        struct schedule_callback_state *state =
     715                talloc_get_type_abort(private_data,
     716                                      struct schedule_callback_state);
     717
     718        if (state->callback != NULL) {
     719                state->callback(state->ctdb, state->status,
     720                                state->private_data);
     721        }
     722        talloc_free(state);
     723}
     724
     725static int
     726schedule_callback_immediate(struct ctdb_context *ctdb,
     727                            void (*callback)(struct ctdb_context *,
     728                                             int, void *),
     729                            void *private_data,
     730                            int status)
     731{
     732        struct schedule_callback_state *state;
     733        struct tevent_immediate *im;
     734
     735        state = talloc_zero(ctdb, struct schedule_callback_state);
     736        if (state == NULL) {
     737                DEBUG(DEBUG_ERR, (__location__ " out of memory\n"));
     738                return -1;
     739        }
     740        im = tevent_create_immediate(state);
     741        if (im == NULL) {
     742                DEBUG(DEBUG_ERR, (__location__ " out of memory\n"));
     743                talloc_free(state);
     744                return -1;
     745        }
     746
     747        state->ctdb = ctdb;
     748        state->callback = callback;
     749        state->private_data = private_data;
     750        state->status = status;
     751        state->im = im;
     752
     753        tevent_schedule_immediate(im, ctdb->ev,
     754                                  schedule_callback_handler, state);
    699755        return 0;
    700756}
     
    808864        state->child = 0;
    809865
     866        /* Nothing to do? */
     867        if (state->scripts->num_scripts == 0) {
     868                int ret = schedule_callback_immediate(ctdb, callback,
     869                                                      private_data, 0);
     870                talloc_free(state);
     871                if (ret != 0) {
     872                        DEBUG(DEBUG_ERR,
     873                              ("Unable to schedule callback for 0 scripts\n"));
     874                        return 1;
     875                }
     876                return 0;
     877        }
     878
     879        state->scripts->scripts[0].status = fork_child_for_script(ctdb, state);
     880        if (state->scripts->scripts[0].status != 0) {
     881                talloc_free(state);
     882                return -1;
     883        }
     884
    810885        if (call == CTDB_EVENT_MONITOR) {
    811886                ctdb->current_monitor = state;
    812887        }
    813888
     889        ctdb->active_events++;
     890
    814891        talloc_set_destructor(state, event_script_destructor);
    815 
    816         ctdb->active_events++;
    817 
    818         /* Nothing to do? */
    819         if (state->scripts->num_scripts == 0) {
    820                 callback(ctdb, 0, private_data);
    821                 talloc_free(state);
    822                 return 0;
    823         }
    824 
    825         state->scripts->scripts[0].status = fork_child_for_script(ctdb, state);
    826         if (state->scripts->scripts[0].status != 0) {
    827                 /* Callback is called from destructor, with fail result. */
    828                 talloc_free(state);
    829                 return 0;
    830         }
    831892
    832893        if (!timeval_is_zero(&state->timeout)) {
     
    10081069        CTDB_NO_MEMORY(ctdb, state);
    10091070
    1010         state->c = talloc_steal(state, c);
     1071        state->c = NULL;
    10111072
    10121073        DEBUG(DEBUG_NOTICE,("Running eventscripts with arguments %s\n", indata.dptr));
     
    10241085        /* tell ctdb_control.c that we will be replying asynchronously */
    10251086        *async_reply = true;
    1026 
     1087        state->c = talloc_steal(state, c);
    10271088        return 0;
    10281089}
Note: See TracChangeset for help on using the changeset viewer.