[systemd-devel] [PATCH] core/socket: we only want one event on standard sockets

Shawn Landden shawn at churchofgit.com
Fri Nov 22 18:56:28 PST 2013


With EPOLLONESHOT we are guaranteed to only recieve one event
until we reload with socket_enter_listening(s), otherwise
multiple events can be generated upon receipt of multiple chunks of data.

We also only want wake-ups when external events happen, i.e.
edge-triggered wakeups.
---
 src/core/socket.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/core/socket.c b/src/core/socket.c
index 5fa4a5a..2f860a4 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -1119,7 +1119,9 @@ static int socket_watch_fds(Socket *s) {
                 if (p->event_source)
                         r = sd_event_source_set_enabled(p->event_source, SD_EVENT_ON);
                 else
-                        r = sd_event_add_io(UNIT(s)->manager->event, p->fd, EPOLLIN, socket_dispatch_io, p, &p->event_source);
+                        r = sd_event_add_io(UNIT(s)->manager->event, p->fd,
+                                        EPOLLIN|EPOLLET|((s->accept || s->distribute) ? 0 : EPOLLONESHOT),
+                                        socket_dispatch_io, p, &p->event_source);
 
                 if (r < 0) {
                         log_warning_unit(UNIT(s)->id, "Failed to watch listening fds: %s", strerror(-r));
-- 
1.8.4.4



More information about the systemd-devel mailing list