about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2008-08-03 15:46:46 +0000
committerUlrich Drepper <drepper@redhat.com>2008-08-03 15:46:46 +0000
commit39e175bb3a158780e95af838087174f317f2444d (patch)
tree9b7922d3794f7fbe6f7adbddd0cb0546af6f049e
parent3f39adace0222729e27cbc040d7475585bb12b3f (diff)
downloadglibc-39e175bb3a158780e95af838087174f317f2444d.tar.gz
glibc-39e175bb3a158780e95af838087174f317f2444d.tar.xz
glibc-39e175bb3a158780e95af838087174f317f2444d.zip
(main_loop_poll): Pass a buffer which is guaranteed to be large enough to read inotify event. Ignore EAGAIN error. Better error message. Add branch predicition. (main_loop_epoll): Likewise.
-rw-r--r--nscd/connections.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/nscd/connections.c b/nscd/connections.c
index 8281533c3b..3395e54fa1 100644
--- a/nscd/connections.c
+++ b/nscd/connections.c
@@ -1868,8 +1868,11 @@ main_loop_poll (void)
 		  bool to_clear[lastdb] = { false, };
 		  union
 		  {
+# ifndef PATH_MAX
+#  define PATH_MAX 1024
+# endif
 		    struct inotify_event i;
-		    char buf[100];
+		    char buf[sizeof (struct inotify_event) + PATH_MAX];
 		  } inev;
 
 		  while (1)
@@ -1878,17 +1881,20 @@ main_loop_poll (void)
 							     sizeof (inev)));
 		      if (nb < (ssize_t) sizeof (struct inotify_event))
 			{
-			  if (nb == -1)
+			  if (__builtin_expect (nb == -1 && errno != EAGAIN,
+						0))
 			    {
 			      /* Something went wrong when reading the inotify
 				 data.  Better disable inotify.  */
+			      dbg_log (_("\
+disabled inotify after read error %d"),
+				       errno);
 			      conns[1].fd = -1;
 			      firstfree = 1;
 			      if (nused == 2)
 				nused = 1;
 			      close (inotify_fd);
 			      inotify_fd = -1;
-			      dbg_log (_("disabled inotify after read error"));
 			    }
 			  break;
 			}
@@ -2047,7 +2053,7 @@ main_loop_epoll (int efd)
 	    union
 	    {
 	      struct inotify_event i;
-	      char buf[100];
+	      char buf[sizeof (struct inotify_event) + PATH_MAX];
 	    } inev;
 
 	    while (1)
@@ -2056,15 +2062,16 @@ main_loop_epoll (int efd)
 				 		 sizeof (inev)));
 		if (nb < (ssize_t) sizeof (struct inotify_event))
 		  {
-		    if (nb == -1)
+		    if (__builtin_expect (nb == -1 && errno != EAGAIN, 0))
 		      {
 			/* Something went wrong when reading the inotify
 			   data.  Better disable inotify.  */
+			dbg_log (_("disabled inotify after read error %d"),
+				 errno);
 			(void) epoll_ctl (efd, EPOLL_CTL_DEL, inotify_fd,
 					  NULL);
 			close (inotify_fd);
 			inotify_fd = -1;
-			dbg_log (_("disabled inotify after read error"));
 		      }
 		    break;
 		  }