… | |
… | |
1716 | #define MIN_STAT_INTERVAL 0.1074891 |
1716 | #define MIN_STAT_INTERVAL 0.1074891 |
1717 | |
1717 | |
1718 | void noinline stat_timer_cb (EV_P_ ev_timer *w_, int revents); |
1718 | void noinline stat_timer_cb (EV_P_ ev_timer *w_, int revents); |
1719 | |
1719 | |
1720 | #if EV_USE_INOTIFY |
1720 | #if EV_USE_INOTIFY |
1721 | # define EV_INOTIFY_BUFSIZE ((PATH_MAX + sizeof (struct inotify_event)) + 2048) |
1721 | # define EV_INOTIFY_BUFSIZE 8192 |
1722 | |
1722 | |
1723 | static void noinline |
1723 | static void noinline |
1724 | infy_add (EV_P_ ev_stat *w) |
1724 | infy_add (EV_P_ ev_stat *w) |
1725 | { |
1725 | { |
1726 | w->wd = inotify_add_watch (fs_fd, w->path, IN_ATTRIB | IN_DELETE_SELF | IN_MOVE_SELF | IN_MODIFY | IN_DONT_FOLLOW | IN_MASK_ADD); |
1726 | w->wd = inotify_add_watch (fs_fd, w->path, IN_ATTRIB | IN_DELETE_SELF | IN_MOVE_SELF | IN_MODIFY | IN_DONT_FOLLOW | IN_MASK_ADD); |
… | |
… | |
1728 | if (w->wd < 0) |
1728 | if (w->wd < 0) |
1729 | { |
1729 | { |
1730 | ev_timer_start (EV_A_ &w->timer); /* this is not race-free, so we still need to recheck periodically */ |
1730 | ev_timer_start (EV_A_ &w->timer); /* this is not race-free, so we still need to recheck periodically */ |
1731 | |
1731 | |
1732 | /* monitor some parent directory for speedup hints */ |
1732 | /* monitor some parent directory for speedup hints */ |
1733 | if (errno == ENOENT || errno == EACCES) |
1733 | if ((errno == ENOENT || errno == EACCES) && strlen (w->path) < 4096) |
1734 | { |
1734 | { |
1735 | char path [PATH_MAX]; |
1735 | char path [4096]; |
1736 | strcpy (path, w->path); |
1736 | strcpy (path, w->path); |
1737 | |
1737 | |
1738 | do |
1738 | do |
1739 | { |
1739 | { |
1740 | int mask = IN_MASK_ADD | IN_DELETE_SELF | IN_MOVE_SELF |
1740 | int mask = IN_MASK_ADD | IN_DELETE_SELF | IN_MOVE_SELF |
… | |
… | |
1744 | |
1744 | |
1745 | if (!pend) |
1745 | if (!pend) |
1746 | break; /* whoops, no '/', complain to your admin */ |
1746 | break; /* whoops, no '/', complain to your admin */ |
1747 | |
1747 | |
1748 | *pend = 0; |
1748 | *pend = 0; |
1749 | w->wd = inotify_add_watch (fs_fd, path, IN_DELETE_SELF | IN_CREATE | IN_MOVED_TO | IN_MASK_ADD); |
1749 | w->wd = inotify_add_watch (fs_fd, path, mask); |
1750 | } |
1750 | } |
1751 | while (w->wd < 0 && (errno == ENOENT || errno == EACCES)); |
1751 | while (w->wd < 0 && (errno == ENOENT || errno == EACCES)); |
1752 | } |
1752 | } |
1753 | } |
1753 | } |
1754 | else |
1754 | else |
… | |
… | |
1759 | } |
1759 | } |
1760 | |
1760 | |
1761 | static void noinline |
1761 | static void noinline |
1762 | infy_del (EV_P_ ev_stat *w) |
1762 | infy_del (EV_P_ ev_stat *w) |
1763 | { |
1763 | { |
1764 | WL w_; |
|
|
1765 | int slot; |
1764 | int slot; |
1766 | int wd = w->wd; |
1765 | int wd = w->wd; |
1767 | |
1766 | |
1768 | if (wd < 0) |
1767 | if (wd < 0) |
1769 | return; |
1768 | return; |
… | |
… | |
1798 | { |
1797 | { |
1799 | w->wd = -1; |
1798 | w->wd = -1; |
1800 | infy_add (EV_A_ w); /* re-add, no matter what */ |
1799 | infy_add (EV_A_ w); /* re-add, no matter what */ |
1801 | } |
1800 | } |
1802 | |
1801 | |
1803 | stat_timer_cb (EV_P_ &w->timer, 0); |
1802 | stat_timer_cb (EV_A_ &w->timer, 0); |
1804 | } |
1803 | } |
1805 | } |
1804 | } |
1806 | } |
1805 | } |
1807 | } |
1806 | } |
1808 | |
1807 | |