bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] tail: add comments noting potential inotify-related problems


From: Jim Meyering
Subject: [PATCH] tail: add comments noting potential inotify-related problems
Date: Mon, 29 Jun 2009 20:46:45 +0200

Hi Giuseppe,

I noticed two potential problems.
The first appears to affects only kernels 2.6.13..2.6.20.
The second one doesn't have to be fixed before the upcoming release.

>From 6d0d1c47b28ea4989a6608e9f7d51218ee0c89ef Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Mon, 29 Jun 2009 20:43:26 +0200
Subject: [PATCH] tail: add comments noting potential inotify-related problems

* src/tail.c (tail_forever_inotify): Add two FIXME comments.
---
 src/tail.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/tail.c b/src/tail.c
index 059ee82..89c43b8 100644
--- a/src/tail.c
+++ b/src/tail.c
@@ -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;
             }

--
1.6.3.3.467.g98a79




reply via email to

[Prev in Thread] Current Thread [Next in Thread]