From: Dana Jansens Date: Mon, 24 Jan 2011 22:05:44 +0000 (-0500) Subject: Avoid blocks on read() for inotify. X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=5de6f71f345513b4cb3643eb7679664297afcb70;p=dana%2Fopenbox.git 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. --- 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)