Avoid blocks on read() for inotify.
authorDana Jansens <danakj@orodu.net>
Mon, 24 Jan 2011 22:05:44 +0000 (17:05 -0500)
committerDana Jansens <danakj@orodu.net>
Sun, 16 Oct 2011 22:54:04 +0000 (18:54 -0400)
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

index 2aff0e394e8e89e2ee92783a85e515ba38fc0010..b55f5282a4fb3be38e4f000466d5ac914202fee7 100644 (file)
@@ -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)