windows-release-locks-at-shutdown-20051108
authorJeffrey Altman <jaltman@secure-endpoints.com>
Wed, 9 Nov 2005 03:00:07 +0000 (03:00 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Wed, 9 Nov 2005 03:00:07 +0000 (03:00 +0000)
remember to release all of the locks we obtained from the file server
at shutdown.

src/WINNT/afsd/afsd_service.c
src/WINNT/afsd/cm_vnodeops.c
src/WINNT/afsd/cm_vnodeops.h

index 32c6752..9992708 100644 (file)
@@ -1,37 +1,4 @@
-/*
- * Copyright 2000, International Business Machines Corporation and others.
- * All Rights Reserved.
- * 
- * This software has been released under the terms of the IBM Public
- * License.  For details, see the LICENSE file in the top-level source
- * directory or online at http://www.openafs.org/dl/license10.html
- */
-/* AFSIFS portions copyright (c) 2005
- * the regents of the university of michigan
- * all rights reserved
- * 
- * permission is granted to use, copy, create derivative works and
- * redistribute this software and such derivative works for any purpose,
- * so long as the name of the university of michigan is not used in
- * any advertising or publicity pertaining to the use or distribution
- * of this software without specific, written prior authorization.  if
- * the above copyright notice or any other identification of the
- * university of michigan is included in any copy of any portion of
- * this software, then the disclaimer below must also be included.
- * 
- * this software is provided as is, without representation from the
- * university of michigan as to its fitness for any purpose, and without
- * warranty by the university of michigan of any kind, either express 
- * or implied, including without limitation the implied warranties of
- * merchantability and fitness for a particular purpose.  the regents
- * of the university of michigan shall not be liable for any damages,   
- * including special, indirect, incidental, or consequential damages, 
- * with respect to any claim arising out or in connection with the use
- * of the software, even if it has been or is hereafter advised of the
- * possibility of such damages.
- */
 
-#include <afs/param.h>
 #include <afs/stds.h>
 
 #include <windows.h>
@@ -1441,6 +1408,11 @@ afsd_Main(DWORD argc, LPTSTR *argv)
                                          
     RpcShutdown();                       
 
+    cm_ReleaseAllLocks();
+
+    rx_Finalize();
+    afsi_log("rx finalization complete");
+
     cm_ShutdownMappedMemory();           
 
 #ifdef REGISTER_POWER_NOTIFICATIONS
index 67f781f..4fd8bd0 100644 (file)
@@ -3606,10 +3606,10 @@ static int cm_KeyEquals(cm_key_t k1, cm_key_t k2, int flags);
 
 /* Called with scp->mx held */
 long cm_UnlockByKey(cm_scache_t * scp,
-                    cm_key_t key,
-                    int flags,
-                    cm_user_t * userp,
-                    cm_req_t * reqp)
+                   cm_key_t key,
+                   int flags,
+                   cm_user_t * userp,
+                    cm_req_t * reqp)
 {
     long code = 0;
     AFSFid tfid;
@@ -4537,3 +4537,38 @@ static int cm_KeyEquals(cm_key_t k1, cm_key_t k2, int flags)
         return (k1 == k2);
     }
 }
+
+void cm_ReleaseAllLocks(void)
+{
+    cm_scache_t *scp;
+    cm_req_t req;
+    cm_user_t *userp;
+    cm_key_t   key;
+    cm_file_lock_t *fileLock;
+    int i;
+
+    for (i = 0; i < cm_data.hashTableSize; i++)
+    {
+       for ( scp = cm_data.hashTablep[i]; scp; scp = scp->nextp ) {
+           while (scp->fileLocksH != NULL) {
+               lock_ObtainMutex(&scp->mx);
+               lock_ObtainWrite(&cm_scacheLock);
+               if (!scp->fileLocksH) {
+                   lock_ReleaseWrite(&cm_scacheLock);
+                   lock_ReleaseMutex(&scp->mx);
+                   break;
+               }
+               fileLock = (cm_file_lock_t *)((char *) scp->fileLocksH - offsetof(cm_file_lock_t, fileq));
+               userp = fileLock->userp;
+               cm_HoldUser(userp);
+               key = fileLock->key;
+               cm_HoldSCacheNoLock(scp);
+               lock_ReleaseWrite(&cm_scacheLock);
+               cm_UnlockByKey(scp, key, 0, userp, &req);
+               cm_ReleaseSCache(scp);
+               cm_ReleaseUser(userp);
+               lock_ReleaseMutex(&scp->mx);
+           }
+       }
+    }
+}
index 569f698..bb2c2aa 100644 (file)
@@ -172,7 +172,9 @@ extern long cm_LockCheckWrite(cm_scache_t *scp,
         LARGE_INTEGER LLength,
         cm_key_t key);
 
-extern void cm_CheckLocks();
+extern void cm_CheckLocks(void);
+
+extern void cm_ReleaseAllLocks(void);
 
 extern long cm_RetryLock(cm_file_lock_t *oldFileLock, int client_is_dead);