ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev.c
(Generate patch)

Comparing libev/ev.c (file contents):
Revision 1.263 by root, Wed Oct 1 18:50:03 2008 UTC vs.
Revision 1.264 by root, Mon Oct 13 23:20:12 2008 UTC

286# include <sys/select.h> 286# include <sys/select.h>
287# endif 287# endif
288#endif 288#endif
289 289
290#if EV_USE_INOTIFY 290#if EV_USE_INOTIFY
291# include <sys/utsname.h>
291# include <sys/inotify.h> 292# include <sys/inotify.h>
292/* some very old inotify.h headers don't have IN_DONT_FOLLOW */ 293/* some very old inotify.h headers don't have IN_DONT_FOLLOW */
293# ifndef IN_DONT_FOLLOW 294# ifndef IN_DONT_FOLLOW
294# undef EV_USE_INOTIFY 295# undef EV_USE_INOTIFY
295# define EV_USE_INOTIFY 0 296# define EV_USE_INOTIFY 0
2496 2497
2497static void noinline 2498static void noinline
2498infy_wd (EV_P_ int slot, int wd, struct inotify_event *ev) 2499infy_wd (EV_P_ int slot, int wd, struct inotify_event *ev)
2499{ 2500{
2500 if (slot < 0) 2501 if (slot < 0)
2501 /* overflow, need to check for all hahs slots */ 2502 /* overflow, need to check for all hash slots */
2502 for (slot = 0; slot < EV_INOTIFY_HASHSIZE; ++slot) 2503 for (slot = 0; slot < EV_INOTIFY_HASHSIZE; ++slot)
2503 infy_wd (EV_A_ slot, wd, ev); 2504 infy_wd (EV_A_ slot, wd, ev);
2504 else 2505 else
2505 { 2506 {
2506 WL w_; 2507 WL w_;
2540infy_init (EV_P) 2541infy_init (EV_P)
2541{ 2542{
2542 if (fs_fd != -2) 2543 if (fs_fd != -2)
2543 return; 2544 return;
2544 2545
2546 /* kernels < 2.6.25 are borked
2547 * http://www.ussg.indiana.edu/hypermail/linux/kernel/0711.3/1208.html
2548 */
2549 {
2550 struct utsname buf;
2551 int major, minor, micro;
2552
2553 fs_fd = -1;
2554
2555 if (uname (&buf))
2556 return;
2557
2558 if (sscanf (buf.release, "%d.%d.%d", &major, &minor, &micro) != 3)
2559 return;
2560
2561 if (major < 2
2562 || (major == 2 && minor < 6)
2563 || (major == 2 && minor == 6 && micro < 25))
2564 return;
2565 }
2566
2545 fs_fd = inotify_init (); 2567 fs_fd = inotify_init ();
2546 2568
2547 if (fs_fd >= 0) 2569 if (fs_fd >= 0)
2548 { 2570 {
2549 ev_io_init (&fs_w, infy_cb, fs_fd, EV_READ); 2571 ev_io_init (&fs_w, infy_cb, fs_fd, EV_READ);
2578 if (fs_fd >= 0) 2600 if (fs_fd >= 0)
2579 infy_add (EV_A_ w); /* re-add, no matter what */ 2601 infy_add (EV_A_ w); /* re-add, no matter what */
2580 else 2602 else
2581 ev_timer_start (EV_A_ &w->timer); 2603 ev_timer_start (EV_A_ &w->timer);
2582 } 2604 }
2583
2584 } 2605 }
2585} 2606}
2586 2607
2587#endif 2608#endif
2588 2609
2624 || w->prev.st_atime != w->attr.st_atime 2645 || w->prev.st_atime != w->attr.st_atime
2625 || w->prev.st_mtime != w->attr.st_mtime 2646 || w->prev.st_mtime != w->attr.st_mtime
2626 || w->prev.st_ctime != w->attr.st_ctime 2647 || w->prev.st_ctime != w->attr.st_ctime
2627 ) { 2648 ) {
2628 #if EV_USE_INOTIFY 2649 #if EV_USE_INOTIFY
2650 if (fs_fd >= 0)
2651 {
2629 infy_del (EV_A_ w); 2652 infy_del (EV_A_ w);
2630 infy_add (EV_A_ w); 2653 infy_add (EV_A_ w);
2631 ev_stat_stat (EV_A_ w); /* avoid race... */ 2654 ev_stat_stat (EV_A_ w); /* avoid race... */
2655 }
2632 #endif 2656 #endif
2633 2657
2634 ev_feed_event (EV_A_ w, EV_STAT); 2658 ev_feed_event (EV_A_ w, EV_STAT);
2635 } 2659 }
2636} 2660}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines