summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Menšík <pemensik@redhat.com>2023-04-17 21:05:00 +0100
committerSimon Kelley <simon@thekelleys.org.uk>2023-04-17 21:05:00 +0100
commitbcb46809dcf8992aeb36a3267e4af4ac1c04f471 (patch)
tree412dbbcd783bf64dd08fdf0dfc9a0506bc58b4ee
parent33635d8564f96cedcef9bf9826cbbca76f28aa81 (diff)
downloaddnsmasq-bcb46809dcf8992aeb36a3267e4af4ac1c04f471.tar.gz
Optimization of socket events handling of dbus.
Reduces calls to locate the file descriptor structure. Should lower CPU usage when monitoring dbus watches.
-rw-r--r--src/dbus.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/dbus.c b/src/dbus.c
index 34cf2f6..ed5e44a 100644
--- a/src/dbus.c
+++ b/src/dbus.c
@@ -958,14 +958,14 @@ void set_dbus_listeners(void)
{
unsigned int flags = dbus_watch_get_flags(w->watch);
int fd = dbus_watch_get_unix_fd(w->watch);
+ int poll_flags = POLLERR;
if (flags & DBUS_WATCH_READABLE)
- poll_listen(fd, POLLIN);
-
+ poll_flags |= POLLIN;
if (flags & DBUS_WATCH_WRITABLE)
- poll_listen(fd, POLLOUT);
+ poll_flags |= POLLOUT;
- poll_listen(fd, POLLERR);
+ poll_listen(fd, poll_flags);
}
}
@@ -979,14 +979,13 @@ static int check_dbus_watches()
{
unsigned int flags = 0;
int fd = dbus_watch_get_unix_fd(w->watch);
-
- if (poll_check(fd, POLLIN))
+ int poll_flags = poll_check(fd, POLLIN|POLLOUT|POLLERR);
+
+ if ((poll_flags & POLLIN) != 0)
flags |= DBUS_WATCH_READABLE;
-
- if (poll_check(fd, POLLOUT))
+ if ((poll_flags & POLLOUT) != 0)
flags |= DBUS_WATCH_WRITABLE;
-
- if (poll_check(fd, POLLERR))
+ if ((poll_flags & POLLERR) != 0)
flags |= DBUS_WATCH_ERROR;
if (flags != 0)