tail: add comments noting potential inotify-related problems
authorJim Meyering <meyering@redhat.com>
Mon, 29 Jun 2009 18:43:26 +0000 (20:43 +0200)
committerJim Meyering <meyering@redhat.com>
Mon, 29 Jun 2009 18:43:26 +0000 (20:43 +0200)
* src/tail.c (tail_forever_inotify): Add two FIXME comments.

src/tail.c

index 059ee82459741c5563a53ecca43eb9c139460077..89c43b8273ca72f141b95dda61d35f0d061f71ce 100644 (file)
@@ -1258,6 +1258,8 @@ tail_forever_inotify (int wd, struct File_spec *f, int n_files)
           len = safe_read (wd, evbuf, evlen);
           evbuf_off = 0;
 
+          /* For kernels prior to 2.6.21, read returns 0 when the buffer
+             is too small.  FIXME: handle that.  */
           if (len == SAFE_READ_ERROR && errno == EINVAL && max_realloc--)
             {
               len = 0;
@@ -1277,8 +1279,10 @@ tail_forever_inotify (int wd, struct File_spec *f, int n_files)
         {
           for (i = 0; i < n_files; i++)
             {
-              if (f[i].parent_wd == ev->wd &&
-                  STREQ (ev->name, f[i].name + f[i].basename_start))
+              /* With N=hundreds of frequently-changing files, this O(N^2)
+                 process might be a problem.  FIXME: use a hash table?  */
+              if (f[i].parent_wd == ev->wd
+                  && STREQ (ev->name, f[i].name + f[i].basename_start))
                 break;
             }