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

[commits] r3961 - in /fsf/trunk/libc: ChangeLog nscd/cache.c



Author: eglibc
Date: Sat Oct 27 00:03:13 2007
New Revision: 3961

Log:
Import glibc-mainline for 2007-10-27

Modified:
    fsf/trunk/libc/ChangeLog
    fsf/trunk/libc/nscd/cache.c

Modified: fsf/trunk/libc/ChangeLog
==============================================================================
--- fsf/trunk/libc/ChangeLog (original)
+++ fsf/trunk/libc/ChangeLog Sat Oct 27 00:03:13 2007
@@ -1,3 +1,8 @@
+2007-10-26  Ulrich Drepper  <drepper@xxxxxxxxxx>
+
+	* nscd/cache.c (prune_cache): Move test for modified file outside
+	of locking.
+
 2007-10-21  Andreas Jaeger  <aj@xxxxxxx>
 
 	* manual/texinfo.tex: Update to latest version.

Modified: fsf/trunk/libc/nscd/cache.c
==============================================================================
--- fsf/trunk/libc/nscd/cache.c (original)
+++ fsf/trunk/libc/nscd/cache.c Sat Oct 27 00:03:13 2007
@@ -229,22 +229,9 @@
       return;
     }
 
-  /* This function can be called from the cleanup thread but also in
-     response to an invalidate command.  Make sure only one thread is
-     running.  When not serving INVALIDATE request, no need for the
-     second to wait around.  */
-  if (fd == -1)
-    {
-      if (pthread_mutex_trylock (&table->prunelock) != 0)
-	/* The work is already being done.  */
-	return;
-    }
-  else
-    pthread_mutex_lock (&table->prunelock);
-
   /* If we check for the modification of the underlying file we invalidate
      the entries also in this case.  */
-  if (table->check_file)
+  if (table->check_file && now != LONG_MAX)
     {
       struct stat64 st;
 
@@ -267,6 +254,21 @@
 	      table->file_mtime = st.st_mtime;
 	    }
 	}
+    }
+
+  /* This function can be called from the cleanup thread but also in
+     response to an invalidate command.  Make sure only one thread is
+     running.  When not serving INVALIDATE request, no need for the
+     second thread to wait around.  */
+  if (__builtin_expect (pthread_mutex_trylock (&table->prunelock) != 0, 0))
+    {
+      /* The work is already being done.  */
+      if (fd == -1)
+	return;
+
+      /* We have to wait until the thread is done and then run again
+	 so that the large NOW value invalidates all entries.  */
+      pthread_mutex_lock (&table->prunelock);
     }
 
   /* We run through the table and find values which are not valid anymore.
@@ -285,6 +287,7 @@
     dbg_log (_("pruning %s cache; time %ld"),
 	     dbnames[table - dbs], (long int) now);
 
+  time_t next_timeout = LONG_MAX;
   do
     {
       ref_t run = table->head->array[--cnt];
@@ -363,14 +366,17 @@
 		}
 	    }
 	  else
-	    assert (dh->usable);
+	    {
+	      assert (dh->usable);
+	      next_timeout = MIN (next_timeout, dh->timeout);
+	    }
 
 	  run = runp->next;
 	}
     }
   while (cnt > 0);
 
-  if (fd != -1)
+  if (__builtin_expect (fd != -1, 0))
     {
       /* Reply to the INVALIDATE initiator that the cache has been
 	 invalidated.  */