X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Flibelogind%2Fsd-event%2Fsd-event.c;h=0f7a0ca7be2bde153730fba22772fb88b6e4216c;hb=a97a730270418e53e9400de5dce7b07c7dacd19a;hp=c3673f08a65a0b1d8d8ff7b214fa442ff1630c03;hpb=f5eb2a086bc5d5d36bc2e4755a1d6b508e202250;p=elogind.git diff --git a/src/libelogind/sd-event/sd-event.c b/src/libelogind/sd-event/sd-event.c index c3673f08a..0f7a0ca7b 100644 --- a/src/libelogind/sd-event/sd-event.c +++ b/src/libelogind/sd-event/sd-event.c @@ -732,7 +732,6 @@ static void event_unmask_signal_data(sd_event *e, struct signal_data *d, int sig /* If all the mask is all-zero we can get rid of the structure */ hashmap_remove(e->signal_data, &d->priority); - assert(!d->current); safe_close(d->fd); free(d); return; @@ -1197,7 +1196,6 @@ _public_ int sd_event_add_signal( return 0; } -#if 0 /// UNNEEDED by elogind _public_ int sd_event_add_child( sd_event *e, sd_event_source **ret, @@ -1290,7 +1288,6 @@ _public_ int sd_event_add_defer( return 0; } -#endif // 0 _public_ int sd_event_add_post( sd_event *e, @@ -1547,14 +1544,15 @@ _public_ int sd_event_source_get_signal(sd_event_source *s) { return s->signal.sig; } +#endif // 0 _public_ int sd_event_source_get_priority(sd_event_source *s, int64_t *priority) { assert_return(s, -EINVAL); assert_return(!event_pid_changed(s->event), -ECHILD); - return s->priority; + *priority = s->priority; + return 0; } -#endif // 0 _public_ int sd_event_source_set_priority(sd_event_source *s, int64_t priority) { int r; @@ -2245,11 +2243,16 @@ static int process_signal(sd_event *e, struct signal_data *d, uint32_t events) { } static int source_dispatch(sd_event_source *s) { + EventSourceType saved_type; int r = 0; assert(s); assert(s->pending || s->type == SOURCE_EXIT); + /* Save the event source type, here, so that we still know it after the event callback which might invalidate + * the event. */ + saved_type = s->type; + if (s->type != SOURCE_DEFER && s->type != SOURCE_EXIT) { r = source_set_pending(s, false); if (r < 0) @@ -2337,7 +2340,7 @@ static int source_dispatch(sd_event_source *s) { if (r < 0) log_debug_errno(r, "Event source %s (type %s) returned error, disabling: %m", - strna(s->description), event_source_type_to_string(s->type)); + strna(s->description), event_source_type_to_string(saved_type)); if (s->n_ref == 0) source_free(s); @@ -2712,7 +2715,6 @@ _public_ int sd_event_run(sd_event *e, uint64_t timeout) { return r; } -#if 0 /// UNNEEDED by elogind _public_ int sd_event_loop(sd_event *e) { int r; @@ -2735,6 +2737,7 @@ finish: return r; } +#if 0 /// UNNEEDED by elogind _public_ int sd_event_get_fd(sd_event *e) { assert_return(e, -EINVAL); @@ -2776,7 +2779,6 @@ _public_ int sd_event_exit(sd_event *e, int code) { return 0; } -#if 0 /// UNNEEDED by elogind _public_ int sd_event_now(sd_event *e, clockid_t clock, uint64_t *usec) { assert_return(e, -EINVAL); assert_return(usec, -EINVAL); @@ -2801,7 +2803,6 @@ _public_ int sd_event_now(sd_event *e, clockid_t clock, uint64_t *usec) { *usec = triple_timestamp_by_clock(&e->timestamp, clock); return 0; } -#endif // 0 _public_ int sd_event_default(sd_event **ret) {