… | |
… | |
2856 | static void noinline |
2856 | static void noinline |
2857 | infy_add (EV_P_ ev_stat *w) |
2857 | infy_add (EV_P_ ev_stat *w) |
2858 | { |
2858 | { |
2859 | 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); |
2859 | 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); |
2860 | |
2860 | |
2861 | if (w->wd < 0) |
2861 | if (w->wd >= 0) |
|
|
2862 | { |
|
|
2863 | struct statfs sfs; |
|
|
2864 | |
|
|
2865 | /* now local changes will be tracked by inotify, but remote changes won't */ |
|
|
2866 | /* unless the filesystem is known to be local, we therefore still poll */ |
|
|
2867 | /* also do poll on <2.6.25, but with normal frequency */ |
|
|
2868 | |
|
|
2869 | if (!fs_2625) |
|
|
2870 | w->timer.repeat = w->interval ? w->interval : DEF_STAT_INTERVAL; |
|
|
2871 | else if (!statfs (w->path, &sfs) |
|
|
2872 | && (sfs.f_type == 0x1373 /* devfs */ |
|
|
2873 | || sfs.f_type == 0xEF53 /* ext2/3 */ |
|
|
2874 | || sfs.f_type == 0x3153464a /* jfs */ |
|
|
2875 | || sfs.f_type == 0x52654973 /* reiser3 */ |
|
|
2876 | || sfs.f_type == 0x01021994 /* tempfs */ |
|
|
2877 | || sfs.f_type == 0x58465342 /* xfs */)) |
|
|
2878 | w->timer.repeat = 0.; /* filesystem is local, kernel new enough */ |
|
|
2879 | else |
|
|
2880 | w->timer.repeat = w->interval ? w->interval : NFS_STAT_INTERVAL; /* remote, use reduced frequency */ |
2862 | { |
2881 | } |
|
|
2882 | else |
|
|
2883 | { |
|
|
2884 | /* can't use inotify, continue to stat */ |
2863 | w->timer.repeat = w->interval ? w->interval : DEF_STAT_INTERVAL; |
2885 | w->timer.repeat = w->interval ? w->interval : DEF_STAT_INTERVAL; |
2864 | ev_timer_again (EV_A_ &w->timer); /* this is not race-free, so we still need to recheck periodically */ |
|
|
2865 | |
2886 | |
2866 | /* monitor some parent directory for speedup hints */ |
2887 | /* if path is not there, monitor some parent directory for speedup hints */ |
2867 | /* note that exceeding the hardcoded path limit is not a correctness issue, */ |
2888 | /* note that exceeding the hardcoded path limit is not a correctness issue, */ |
2868 | /* but an efficiency issue only */ |
2889 | /* but an efficiency issue only */ |
2869 | if ((errno == ENOENT || errno == EACCES) && strlen (w->path) < 4096) |
2890 | if ((errno == ENOENT || errno == EACCES) && strlen (w->path) < 4096) |
2870 | { |
2891 | { |
2871 | char path [4096]; |
2892 | char path [4096]; |
… | |
… | |
2887 | while (w->wd < 0 && (errno == ENOENT || errno == EACCES)); |
2908 | while (w->wd < 0 && (errno == ENOENT || errno == EACCES)); |
2888 | } |
2909 | } |
2889 | } |
2910 | } |
2890 | |
2911 | |
2891 | if (w->wd >= 0) |
2912 | if (w->wd >= 0) |
2892 | { |
|
|
2893 | struct statfs sfs; |
|
|
2894 | |
|
|
2895 | wlist_add (&fs_hash [w->wd & (EV_INOTIFY_HASHSIZE - 1)].head, (WL)w); |
2913 | wlist_add (&fs_hash [w->wd & (EV_INOTIFY_HASHSIZE - 1)].head, (WL)w); |
2896 | |
2914 | |
2897 | /* now local changes will be tracked by inotify, but remote changes won't */ |
2915 | /* now re-arm timer, if required */ |
2898 | /* unless the filesystem is known to be local, we therefore still poll */ |
2916 | if (ev_is_active (&w->timer)) ev_ref (EV_A); |
2899 | /* also do poll on <2.6.25, but with normal frequency */ |
|
|
2900 | |
|
|
2901 | if (fs_2625 && !statfs (w->path, &sfs)) |
|
|
2902 | if (sfs.f_type == 0x1373 /* devfs */ |
|
|
2903 | || sfs.f_type == 0xEF53 /* ext2/3 */ |
|
|
2904 | || sfs.f_type == 0x3153464a /* jfs */ |
|
|
2905 | || sfs.f_type == 0x52654973 /* reiser3 */ |
|
|
2906 | || sfs.f_type == 0x01021994 /* tempfs */ |
|
|
2907 | || sfs.f_type == 0x58465342 /* xfs */) |
|
|
2908 | return; |
|
|
2909 | |
|
|
2910 | w->timer.repeat = w->interval ? w->interval : fs_2625 ? NFS_STAT_INTERVAL : DEF_STAT_INTERVAL; |
|
|
2911 | ev_timer_again (EV_A_ &w->timer); |
2917 | ev_timer_again (EV_A_ &w->timer); |
2912 | } |
2918 | if (ev_is_active (&w->timer)) ev_unref (EV_A); |
2913 | } |
2919 | } |
2914 | |
2920 | |
2915 | static void noinline |
2921 | static void noinline |
2916 | infy_del (EV_P_ ev_stat *w) |
2922 | infy_del (EV_P_ ev_stat *w) |
2917 | { |
2923 | { |
… | |
… | |
3062 | w->wd = -1; |
3068 | w->wd = -1; |
3063 | |
3069 | |
3064 | if (fs_fd >= 0) |
3070 | if (fs_fd >= 0) |
3065 | infy_add (EV_A_ w); /* re-add, no matter what */ |
3071 | infy_add (EV_A_ w); /* re-add, no matter what */ |
3066 | else |
3072 | else |
|
|
3073 | { |
|
|
3074 | w->timer.repeat = w->interval ? w->interval : DEF_STAT_INTERVAL; |
|
|
3075 | if (ev_is_active (&w->timer)) ev_ref (EV_A); |
3067 | ev_timer_again (EV_A_ &w->timer); |
3076 | ev_timer_again (EV_A_ &w->timer); |
|
|
3077 | if (ev_is_active (&w->timer)) ev_unref (EV_A); |
|
|
3078 | } |
3068 | } |
3079 | } |
3069 | } |
3080 | } |
3070 | } |
3081 | } |
3071 | |
3082 | |
3072 | #endif |
3083 | #endif |
… | |
… | |
3142 | |
3153 | |
3143 | if (fs_fd >= 0) |
3154 | if (fs_fd >= 0) |
3144 | infy_add (EV_A_ w); |
3155 | infy_add (EV_A_ w); |
3145 | else |
3156 | else |
3146 | #endif |
3157 | #endif |
|
|
3158 | { |
3147 | ev_timer_again (EV_A_ &w->timer); |
3159 | ev_timer_again (EV_A_ &w->timer); |
|
|
3160 | ev_unref (EV_A); |
|
|
3161 | } |
3148 | |
3162 | |
3149 | ev_start (EV_A_ (W)w, 1); |
3163 | ev_start (EV_A_ (W)w, 1); |
3150 | |
3164 | |
3151 | EV_FREQUENT_CHECK; |
3165 | EV_FREQUENT_CHECK; |
3152 | } |
3166 | } |
… | |
… | |
3161 | EV_FREQUENT_CHECK; |
3175 | EV_FREQUENT_CHECK; |
3162 | |
3176 | |
3163 | #if EV_USE_INOTIFY |
3177 | #if EV_USE_INOTIFY |
3164 | infy_del (EV_A_ w); |
3178 | infy_del (EV_A_ w); |
3165 | #endif |
3179 | #endif |
|
|
3180 | |
|
|
3181 | if (ev_is_active (&w->timer)) |
|
|
3182 | { |
|
|
3183 | ev_ref (EV_A); |
3166 | ev_timer_stop (EV_A_ &w->timer); |
3184 | ev_timer_stop (EV_A_ &w->timer); |
|
|
3185 | } |
3167 | |
3186 | |
3168 | ev_stop (EV_A_ (W)w); |
3187 | ev_stop (EV_A_ (W)w); |
3169 | |
3188 | |
3170 | EV_FREQUENT_CHECK; |
3189 | EV_FREQUENT_CHECK; |
3171 | } |
3190 | } |