]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
afs: Refactor DoLockWarning
authorAndrew Deason <adeason@sinenomine.net>
Fri, 31 Jan 2014 22:36:44 +0000 (16:36 -0600)
committerStephan Wiesand <stephan.wiesand@desy.de>
Fri, 14 Mar 2014 12:44:12 +0000 (05:44 -0700)
Change DoLockWarning around a little bit, so subsequent changes are
easier to follow. Move lastWarnTime/lastWarnPid so they are only
usable within this function.

This commit should incur no functional change.

Reviewed-on: http://gerrit.openafs.org/10794
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: D Brashear <shadow@your-file-system.com>
(cherry picked from commit c73883e7846fa0421cfac29830c27c9b6aacf5ed)

Change-Id: Ie419aa5110f9c72f99514c8159c10582747601db
Reviewed-on: http://gerrit.openafs.org/10837
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: D Brashear <shadow@your-file-system.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
src/afs/VNOPS/afs_vnop_flock.c
src/afs/afs_init.c
src/afs/afs_prototypes.h

index 13151ea279aa5b0870c6db226b4ab654ef1e5e85..5b0df76de092384c64c2950a2aa0a3ce7c772b6f 100644 (file)
@@ -36,7 +36,6 @@ static int GetFlockCount(struct vcache *avc, struct vrequest *areq);
 static int lockIdcmp2(struct AFS_FLOCK *flock1, struct vcache *vp,
                      struct SimpleLocks *alp, int onlymine,
                      int clid);
-static void DoLockWarning(afs_ucred_t * acred);
 
 /* int clid;  * non-zero on SGI, OSF, SunOS, Darwin, xBSD ** XXX ptr type */
 
@@ -517,42 +516,48 @@ HandleFlock(struct vcache *avc, int acom, struct vrequest *areq,
 
 
 /* warn a user that a lock has been ignored */
-afs_int32 lastWarnTime = 0;    /* this is used elsewhere */
-static afs_int32 lastWarnPid = 0;
 static void
 DoLockWarning(afs_ucred_t * acred)
 {
-    afs_int32 now;
+    static afs_uint32 lastWarnTime;
+    static pid_t lastWarnPid;
+
+    afs_uint32 now;
     pid_t pid = MyPidxx2Pid(MyPidxx);
     char *procname;
+    const char *message;
 
     now = osi_Time();
 
     AFS_STATCNT(DoLockWarning);
+
     /* check if we've already warned this user recently */
-    if (!((now < lastWarnTime + 120) && (lastWarnPid == pid))) {
-       procname = afs_osi_Alloc(256);
+    if ((now < lastWarnTime + 120) && (lastWarnPid == pid)) {
+       return;
+    }
+
+    procname = afs_osi_Alloc(256);
 
-       if (!procname)
-           return;
+    if (!procname)
+       return;
 
-       /* Copies process name to allocated procname, see osi_machdeps for details of macro */
-       osi_procname(procname, 256);
-       procname[255] = '\0';
+    /* Copies process name to allocated procname, see osi_machdeps for details of macro */
+    osi_procname(procname, 256);
+    procname[255] = '\0';
+
+    lastWarnTime = now;
+    lastWarnPid = pid;
 
-       /* otherwise, it is time to nag the user */
-       lastWarnTime = now;
-       lastWarnPid = pid;
 #ifdef AFS_LINUX26_ENV
-       afs_warnuser
-           ("afs: byte-range locks only enforced for processes on this machine (pid %d (%s), user %ld).\n", pid, procname, (long)afs_cr_uid(acred));
+    message = "byte-range locks only enforced for processes on this machine";
 #else
-       afs_warnuser
-           ("afs: byte-range lock/unlock ignored; make sure no one else is running this program (pid %d (%s), user %ld).\n", pid, procname, (long)afs_cr_uid(acred));
+    message = "byte-range lock/unlock ignored; make sure no one else is running this program";
 #endif
-       afs_osi_Free(procname, 256);
-    }
-    return;
+
+    afs_warnuser("afs: %s (pid %d (%s), user %ld).\n",
+                 message, pid, procname, (long)afs_cr_uid(acred));
+
+    afs_osi_Free(procname, 256);
 }
 
 
index 431d89dd0ee48f4cff298bf748cd241c53537ca0..43fa5b4cf1a1c70b971fff5af79db21125e93215 100644 (file)
@@ -726,9 +726,6 @@ shutdown_vnodeops(void)
 {
     AFS_STATCNT(shutdown_vnodeops);
     if (afs_cold_shutdown) {
-#ifndef        AFS_SUN5_ENV            /* XXX */
-       lastWarnTime = 0;
-#endif
 #ifndef AFS_LINUX20_ENV
        afs_rd_stash_i = 0;
 #endif
index d8c4b89045532649f7776cd3d1e2ce026bc894b8..3bab010a934e2280131f630615ce3b3d934eb568 100644 (file)
@@ -1166,8 +1166,6 @@ int afs_fid(OSI_VC_DECL(avc), struct fid **fidpp);
 #endif
 
 /* VNOPS/afs_vnop_flock.c */
-extern afs_int32 lastWarnTime;
-
 extern void lockIdSet(struct AFS_FLOCK *flock, struct SimpleLocks *slp,
                      int clid);
 extern int HandleFlock(struct vcache *avc, int acom,