From: Kirill A. Korinsky Subject: event_asr_dispatch: respect error from event_add To: OpenBSD tech Date: Fri, 14 Jun 2024 21:55:02 +0100 tech@, I noticed that event_asr_dispatch never checks the return of event_add, which can lead to a kind of deadlock when an application expects the callback to fire, but it doesn't fire because asr_run returned error, and it can't schedule the new attempt. Here is a suggested diff that sets ar_errno and ar_h_errno and fires the callback. diff --git lib/libevent/event.c lib/libevent/event.c index 26bc37dea76..007564a8b2c 100644 --- lib/libevent/event.c +++ lib/libevent/event.c @@ -951,7 +951,12 @@ event_asr_dispatch(int fd __attribute__((__unused__)), event_asr_dispatch, eva); tv.tv_sec = ar.ar_timeout / 1000; tv.tv_usec = (ar.ar_timeout % 1000) * 1000; - event_add(&eva->ev, &tv); + if (event_add(&eva->ev, &tv)) { + ar.ar_errno = errno; + ar.ar_h_errno = NETDB_INTERNAL; + eva->cb(&ar, eva->arg); + free(eva); + } } } -- wbr, Kirill