From 31bc8cb7cd9ea6dfb37071722cb47e8c2684e938 Mon Sep 17 00:00:00 2001 From: Richard Turner Date: Fri, 16 Jul 2021 14:50:37 -0400 Subject: [PATCH] Check for pending event before reinitializing the event. Signed-off-by: Richard Turner --- src/xcdbus.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/xcdbus.c b/src/xcdbus.c index f9b7ef5..05b0dfc 100644 --- a/src/xcdbus.c +++ b/src/xcdbus.c @@ -280,6 +280,7 @@ watch_add_event (DBusWatch * watch, void *_c) { xcdbus_conn_t *c = (xcdbus_conn_t *) _c; int fd = dbus_watch_get_unix_fd (watch); + int pending; if (dbus_watch_get_enabled (watch)) { @@ -301,7 +302,13 @@ watch_add_event (DBusWatch * watch, void *_c) w->dbw = watch; } - event_set(&w->ev, w->fd, ev_type, event_cb, w); + pending = event_pending(&w->ev, ev_type, NULL); + + /* Make sure we don't call event_set on an already pending event! */ + if (!pending) { + event_set(&w->ev, w->fd, ev_type, event_cb, w); + } + event_add(&w->ev, NULL); }