Ignore:
Timestamp:
Mar 11, 2009, 9:14:55 AM (16 years ago)
Author:
Paul Smedley
Message:

Add 'missing' 3.0.34 diffs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.0/source/lib/events.c

    r1 r165  
    6565        DEBUG(10, ("Destroying timed event %lx \"%s\"\n", (unsigned long)te,
    6666                te->event_name));
    67         DLIST_REMOVE(te->event_ctx->timed_events, te);
     67        if (te->event_ctx) {
     68                DLIST_REMOVE(te->event_ctx->timed_events, te);
     69        }
    6870        return 0;
    6971}
     
    135137        struct event_context *event_ctx = fde->event_ctx;
    136138
    137         DLIST_REMOVE(event_ctx->fd_events, fde);
     139        if (event_ctx) {
     140                DLIST_REMOVE(event_ctx->fd_events, fde);
     141        }
    138142        return 0;
    139143}
     
    298302}
    299303
     304static int event_context_destructor(struct event_context *ev)
     305{
     306        while (ev->fd_events != NULL) {
     307                ev->fd_events->event_ctx = NULL;
     308                DLIST_REMOVE(ev->fd_events, ev->fd_events);
     309        }
     310        while (ev->timed_events != NULL) {
     311                ev->timed_events->event_ctx = NULL;
     312                DLIST_REMOVE(ev->timed_events, ev->timed_events);
     313        }
     314        return 0;
     315}
     316
     317void event_context_reinit(struct event_context *ev)
     318{
     319        event_context_destructor(ev);
     320        return;
     321}
     322
    300323struct event_context *event_context_init(TALLOC_CTX *mem_ctx)
    301324{
    302         return TALLOC_ZERO_P(NULL, struct event_context);
    303 }
    304 
    305 int set_event_dispatch_time(struct event_context *event_ctx,
    306                             const char *event_name, struct timeval when)
    307 {
    308         struct timed_event *te;
    309 
    310         for (te = event_ctx->timed_events; te; te = te->next) {
    311                 if (strcmp(event_name, te->event_name) == 0) {
    312                         DLIST_REMOVE(event_ctx->timed_events, te);
    313                         te->when = when;
    314                         add_event_by_time(te);
    315                         return 1;
    316                 }
    317         }
    318         return 0;
    319 }
    320 
    321 /* Returns 1 if event was found and cancelled, 0 otherwise. */
    322 
    323 int cancel_named_event(struct event_context *event_ctx,
    324                        const char *event_name)
    325 {
    326         struct timed_event *te;
    327 
    328         for (te = event_ctx->timed_events; te; te = te->next) {
    329                 if (strcmp(event_name, te->event_name) == 0) {
    330                         TALLOC_FREE(te);
    331                         return 1;
    332                 }
    333         }
    334         return 0;
    335 }
     325        struct event_context *result;
     326
     327        result = TALLOC_ZERO_P(mem_ctx, struct event_context);
     328        if (result == NULL) {
     329                return NULL;
     330        }
     331
     332        talloc_set_destructor(result, event_context_destructor);
     333        return result;
     334}
Note: See TracChangeset for help on using the changeset viewer.