summaryrefslogtreecommitdiff
path: root/ev.c
diff options
context:
space:
mode:
authorroot <root>2008-10-13 23:20:12 +0000
committerroot <root>2008-10-13 23:20:12 +0000
commit88681d910ed1d5eaea3c75b6ffb560e77c39428b (patch)
tree64221c60b9beacf87830d324bdac12e4263d720b /ev.c
parenta846d3eb2ec52fa4f189ec935266c1109b2f4bcf (diff)
*** empty log message ***
Diffstat (limited to 'ev.c')
-rw-r--r--ev.c34
1 files changed, 29 insertions, 5 deletions
diff --git a/ev.c b/ev.c
index 617f5ad..1d041fe 100644
--- a/ev.c
+++ b/ev.c
@@ -288,6 +288,7 @@ extern "C" {
#endif
#if EV_USE_INOTIFY
+# include <sys/utsname.h>
# include <sys/inotify.h>
/* some very old inotify.h headers don't have IN_DONT_FOLLOW */
# ifndef IN_DONT_FOLLOW
@@ -2498,7 +2499,7 @@ static void noinline
infy_wd (EV_P_ int slot, int wd, struct inotify_event *ev)
{
if (slot < 0)
- /* overflow, need to check for all hahs slots */
+ /* overflow, need to check for all hash slots */
for (slot = 0; slot < EV_INOTIFY_HASHSIZE; ++slot)
infy_wd (EV_A_ slot, wd, ev);
else
@@ -2542,6 +2543,27 @@ infy_init (EV_P)
if (fs_fd != -2)
return;
+ /* kernels < 2.6.25 are borked
+ * http://www.ussg.indiana.edu/hypermail/linux/kernel/0711.3/1208.html
+ */
+ {
+ struct utsname buf;
+ int major, minor, micro;
+
+ fs_fd = -1;
+
+ if (uname (&buf))
+ return;
+
+ if (sscanf (buf.release, "%d.%d.%d", &major, &minor, &micro) != 3)
+ return;
+
+ if (major < 2
+ || (major == 2 && minor < 6)
+ || (major == 2 && minor == 6 && micro < 25))
+ return;
+ }
+
fs_fd = inotify_init ();
if (fs_fd >= 0)
@@ -2580,7 +2602,6 @@ infy_fork (EV_P)
else
ev_timer_start (EV_A_ &w->timer);
}
-
}
}
@@ -2626,9 +2647,12 @@ stat_timer_cb (EV_P_ ev_timer *w_, int revents)
|| w->prev.st_ctime != w->attr.st_ctime
) {
#if EV_USE_INOTIFY
- infy_del (EV_A_ w);
- infy_add (EV_A_ w);
- ev_stat_stat (EV_A_ w); /* avoid race... */
+ if (fs_fd >= 0)
+ {
+ infy_del (EV_A_ w);
+ infy_add (EV_A_ w);
+ ev_stat_stat (EV_A_ w); /* avoid race... */
+ }
#endif
ev_feed_event (EV_A_ w, EV_STAT);