diff options
author | root <root> | 2007-11-28 11:53:37 +0000 |
---|---|---|
committer | root <root> | 2007-11-28 11:53:37 +0000 |
commit | e53306e99926168d590f09e39ec05ad229799811 (patch) | |
tree | 0f6f8ebf5494939b4ee4a176a34760b876f8fbf6 | |
parent | 4e62f1267caf106a83789131419fc7d2853bcd4f (diff) |
the dreaded fork
-rw-r--r-- | ev.c | 37 |
1 files changed, 37 insertions, 0 deletions
@@ -987,6 +987,8 @@ loop_destroy (EV_P) backend = 0; } +void inline_size infy_fork (EV_P); + void inline_size loop_fork (EV_P) { @@ -999,6 +1001,9 @@ loop_fork (EV_P) #if EV_USE_EPOLL if (backend == EVBACKEND_EPOLL ) epoll_fork (EV_A); #endif +#if EV_USE_INOTIFY + infy_fork (EV_A); +#endif if (ev_is_active (&sigev)) { @@ -1833,6 +1838,38 @@ infy_init (EV_P) } } +void inline_size +infy_fork (EV_P) +{ + int slot; + + if (fs_fd < 0) + return; + + close (fs_fd); + fs_fd = inotify_init (); + + for (slot = 0; slot < EV_INOTIFY_HASHSIZE; ++slot) + { + WL w_ = fs_hash [slot].head; + fs_hash [slot].head = 0; + + while (w_) + { + ev_stat *w = (ev_stat *)w_; + w_ = w_->next; /* lets us add this watcher */ + + w->wd = -1; + + if (fs_fd >= 0) + infy_add (EV_A_ w); /* re-add, no matter what */ + else + ev_timer_start (EV_A_ &w->timer); + } + + } +} + #endif void |