From 1bdcd5a2a4b6aa6d1c5d46f74073d2ef8195e129 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Mon, 24 Jan 2011 17:05:44 -0500 Subject: [PATCH] Avoid blocks on read() for inotify. When we come into the function we don't know how much data is available to read. So just read a single event and return, so poll can figure out if there is more for us or not. --- obt/watch_inotify.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/obt/watch_inotify.c b/obt/watch_inotify.c index 2aff0e39..b55f5282 100644 --- a/obt/watch_inotify.c +++ b/obt/watch_inotify.c @@ -301,6 +301,11 @@ static gboolean source_read(GSource *source, GSourceFunc cb, gpointer data) } g_free(full_path); + + /* only read one event at a time, so poll can tell us if there + is another one ready, and we don't block on the read() + needlessly. */ + break; } if (state == READING_NAME_HEAP) -- 2.39.2