diff --git a/event.c b/event.c index b98ba953..e1b76adf 100644 --- a/event.c +++ b/event.c @@ -1846,6 +1846,8 @@ event_assign(struct event *ev, struct event_base *base, evutil_socket_t fd, shor { if (!base) base = current_base; + if (arg == &event_self_cbarg_ptr_) + arg = ev; event_debug_assert_not_added_(ev); diff --git a/include/event2/event.h b/include/event2/event.h index 9b584836..41df727f 100644 --- a/include/event2/event.h +++ b/include/event2/event.h @@ -859,8 +859,13 @@ typedef void (*event_callback_fn)(evutil_socket_t, short, void *); struct event *ev = event_new(base, sock, events, callback, %event_self_cbarg()); - @return a value to be passed as the callback argument to event_new(). - @see event_new() + For consistency with event_new(), it is possible to pass the return value + of this function as the callback argument for event_assign() – this + achieves the same result as passing the event in directly. + + @return a value to be passed as the callback argument to event_new() or + event_assign(). + @see event_new(), event_assign() */ void *event_self_cbarg(void);