cvs-cvs
[Top][All Lists]
Advanced

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

[Cvs-cvs] ccvs/src ChangeLog lock.c sanity.sh


From: Mark D. Baushke
Subject: [Cvs-cvs] ccvs/src ChangeLog lock.c sanity.sh
Date: Tue, 20 Mar 2007 16:56:14 +0000

CVSROOT:        /cvsroot/cvs
Module name:    ccvs
Changes by:     Mark D. Baushke <mdb>   07/03/20 16:56:13

Modified files:
        src            : ChangeLog lock.c sanity.sh 

Log message:
        * lock.c (lockers_uid): New file scope global.
        (unset_lockers_name): New function.
        (lock_list_promotably): Use it.
        (lock_wait): Handle NULL lockers_name value.
        (set_lockers_name): Some systems with huge NIS+ maps may take more
        than a few seconds for the getpwuid() call. Cache the result to
        avoid hammering the system.
        * sanity.sh (lockfiles-10,lockfiles-20): Add a few more seconds to
        the sleep before removing the lockfile to aid with the above
        problem.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/ChangeLog?cvsroot=cvs&r1=1.3506&r2=1.3507
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/lock.c?cvsroot=cvs&r1=1.120&r2=1.121
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/sanity.sh?cvsroot=cvs&r1=1.1173&r2=1.1174

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/ChangeLog,v
retrieving revision 1.3506
retrieving revision 1.3507
diff -u -b -r1.3506 -r1.3507
--- ChangeLog   16 Mar 2007 04:08:55 -0000      1.3506
+++ ChangeLog   20 Mar 2007 16:56:13 -0000      1.3507
@@ -1,3 +1,16 @@
+2007-03-20  Mark D. Baushke  <address@hidden>
+
+       * lock.c (lockers_uid): New file scope global.
+       (unset_lockers_name): New function.
+       (lock_list_promotably): Use it.
+       (lock_wait): Handle NULL lockers_name value.
+       (set_lockers_name): Some systems with huge NIS+ maps may take more
+       than a few seconds for the getpwuid() call. Cache the result to
+       avoid hammering the system.
+       * sanity.sh (lockfiles-10,lockfiles-20): Add a few more seconds to
+       the sleep before removing the lockfile to aid with the above
+       problem.
+
 2007-03-12  Mark D. Baushke  <address@hidden>
 
        * rcs.c (findnextmagicrev_proc): New function to find 

Index: lock.c
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/lock.c,v
retrieving revision 1.120
retrieving revision 1.121
diff -u -b -r1.120 -r1.121
--- lock.c      26 May 2006 19:25:57 -0000      1.120
+++ lock.c      20 Mar 2007 16:56:13 -0000      1.121
@@ -116,10 +116,14 @@
 static int set_lock (struct lock *lock, int will_wait);
 static void clear_lock (struct lock *lock);
 static void set_lockers_name (struct stat *statp);
+static void unset_lockers_name (void);
 
 /* Malloc'd array containing the username of the whoever has the lock.
    Will always be non-NULL in the cases where it is needed.  */
 static char *lockers_name;
+/* The uid of the lockers_name is cached here as getpwuid() can be
+   expensive on some systems. */
+static uid_t lockers_uid;
 /* Malloc'd array specifying name of a readlock within a directory.
    Or NULL if none.  */
 static char *readlock;
@@ -879,7 +883,7 @@
     tm_p = gmtime (&now);
     msg = Xasprintf ("[%8.8s] waiting for %s's lock in %s",
                     (tm_p ? asctime (tm_p) : ctime (&now)) + 11,
-                    lockers_name, repos);
+                    lockers_name ? lockers_name : "unknown", repos);
     error (0, 0, "%s", msg);
     /* Call cvs_flusherr to ensure that the user sees this message as
        soon as possible.  */
@@ -946,9 +950,7 @@
        lock_error = L_OK;              /* init for set_promotablelock_proc */
        lock_error_repos = NULL;        /* init for set_promotablelock_proc */
        locklist = list;                /* init for Lock_Cleanup */
-       if (lockers_name != NULL)
-           free (lockers_name);
-       lockers_name = xstrdup ("unknown");
+       unset_lockers_name ();
 
        (void) walklist (list, set_promotablelock_proc, NULL);
 
@@ -996,6 +998,9 @@
 {
     struct passwd *pw;
 
+    if (lockers_name != NULL && lockers_uid == statp->st_uid)
+        return;                        /* optimization to avoid getpwuid() 
calls */
+
     if (lockers_name != NULL)
        free (lockers_name);
     pw = (struct passwd *) getpwuid (statp->st_uid);
@@ -1003,6 +1008,21 @@
        lockers_name = xstrdup (pw->pw_name);
     else
        lockers_name = Xasprintf ("uid%lu", (unsigned long) statp->st_uid);
+
+    lockers_uid = statp->st_uid; /* cache for later use */
+}
+
+
+
+/*
+ * Reset any old locker name information.
+ */
+static void
+unset_lockers_name (void)
+{
+    if (lockers_name != NULL)
+       free (lockers_name);
+    lockers_name = NULL;
 }
 
 

Index: sanity.sh
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/sanity.sh,v
retrieving revision 1.1173
retrieving revision 1.1174
diff -u -b -r1.1173 -r1.1174
--- sanity.sh   16 Mar 2007 04:08:56 -0000      1.1173
+++ sanity.sh   20 Mar 2007 16:56:13 -0000      1.1174
@@ -24140,7 +24140,7 @@
 
          # 3. Don't read when write locks present...
          mkdir "$TESTDIR/locks/first-dir/#cvs.lock"
-         (sleep 5; rmdir "$TESTDIR/locks/first-dir/#cvs.lock")&
+         (sleep 8; rmdir "$TESTDIR/locks/first-dir/#cvs.lock")&
          dotest lockfiles-10 "$testcvs -q co -l first-dir" \
 "$SPROG checkout: \[[0-9:]*\] waiting for $username's lock in 
$CVSROOT_DIRNAME/first-dir
 $SPROG checkout: \[[0-9:]*\] obtained lock in $CVSROOT_DIRNAME/first-dir"
@@ -24224,7 +24224,7 @@
          # 10. Don't write when history locks are present...
          echo have you ever heard a poem quite so vile\? 
>>first-dir/sdir/ssdir/file1
          mkdir "$TESTDIR/locks/CVSROOT/#cvs.history.lock"
-         (sleep 5; rmdir "$TESTDIR/locks/CVSROOT/#cvs.history.lock")&
+         (sleep 8; rmdir "$TESTDIR/locks/CVSROOT/#cvs.history.lock")&
          dotest lockfiles-20 "$testcvs -q ci -mnot-up-to-date first-dir" \
 "$CVSROOT_DIRNAME/first-dir/sdir/ssdir/file1,v  <--  first-dir/sdir/ssdir/file1
 new revision: 1\.5; previous revision: 1\.4




reply via email to

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