Windows: move debug break in afsd_notifier
[openafs.git] / src / WINNT / afsd / afsd_service.c
index 82709c4..b7bb6a4 100644 (file)
@@ -83,6 +83,11 @@ static void afsd_notifier(char *msgp, char *filep, long line)
         afsd_printStack(GetCurrentThread(), &context);
     }
 
+#ifdef DEBUG
+    if (IsDebuggerPresent())
+        DebugBreak();
+#endif
+
     afsi_log("--- begin dump ---");
     cm_MemDumpDirStats(afsi_file, "a", 0);
     cm_MemDumpBPlusStats(afsi_file, "a", 0);
@@ -90,14 +95,12 @@ static void afsd_notifier(char *msgp, char *filep, long line)
     cm_DumpVolumes(afsi_file, "a", 0);
     cm_DumpSCache(afsi_file, "a", 0);
     cm_DumpBufHashTable(afsi_file, "a", 0);
+    cm_DumpServers(afsi_file, "a", 0);
     smb_DumpVCP(afsi_file, "a", 0);                    
+    rx_DumpPackets(afsi_file, "a");
+    rx_DumpCalls(afsi_file, "a");
     afsi_log("--- end   dump ---");
     
-#ifdef DEBUG
-    if (IsDebuggerPresent())
-        DebugBreak();  
-#endif
-
     GenerateMiniDump(NULL);
 
     SetEvent(WaitToTerminate);
@@ -464,7 +467,7 @@ static DWORD __stdcall MountGlobalDrivesThread(void * notUsed)
 
             nr.dwScope = RESOURCE_GLOBALNET;              /* ignored parameter */
             nr.dwType=RESOURCETYPE_DISK;
-            nr.lpLocalName=szDriveToMapTo;
+            nr.lpLocalName=strlen(szDriveToMapTo) > 0 ? szDriveToMapTo : NULL;
             nr.lpRemoteName=szAfsPath;
             nr.dwDisplayType = RESOURCEDISPLAYTYPE_SHARE; /* ignored parameter */
             nr.dwUsage = RESOURCEUSAGE_CONNECTABLE;       /* ignored parameter */
@@ -1215,7 +1218,7 @@ afsd_Main(DWORD argc, LPTSTR *argv)
     }
 
     /* allow an exit to be called prior to any initialization */
-    hHookDll = LoadLibrary(AFSD_HOOK_DLL);
+    hHookDll = cm_LoadAfsdHookLib();
     if (hHookDll)
     {
         BOOL hookRc = TRUE;
@@ -1280,14 +1283,8 @@ afsd_Main(DWORD argc, LPTSTR *argv)
             SetServiceStatus(StatusHandle, &ServiceStatus);
         }
 #endif
-        code = afsd_InitDaemons(&reason);
-        if (code != 0) {
-            afsi_log("afsd_InitDaemons failed: %s (code = %d)", reason, code);
-                       osi_panic(reason, __FILE__, __LINE__);
-        }
-
         /* allow an exit to be called post rx initialization */
-        hHookDll = LoadLibrary(AFSD_HOOK_DLL);
+        hHookDll = cm_LoadAfsdHookLib();
         if (hHookDll)
         {
             BOOL hookRc = TRUE;
@@ -1325,9 +1322,6 @@ afsd_Main(DWORD argc, LPTSTR *argv)
         /* Notify any volume status handlers that the cache manager has started */
         cm_VolStatus_Service_Started();
 
-/* the following ifdef chooses the mode of operation for the service.  to enable
- * a runtime flag (instead of compile-time), pioctl() would need to dynamically
- * determine the mode, in order to use the correct ioctl special-file path. */
         code = afsd_InitSMB(&reason, MessageBox);
         if (code != 0) {
             afsi_log("afsd_InitSMB failed: %s (code = %d)", reason, code);
@@ -1335,7 +1329,7 @@ afsd_Main(DWORD argc, LPTSTR *argv)
         }
 
         /* allow an exit to be called post smb initialization */
-        hHookDll = LoadLibrary(AFSD_HOOK_DLL);
+        hHookDll = cm_LoadAfsdHookLib();
         if (hHookDll)
         {
             BOOL hookRc = TRUE;
@@ -1364,6 +1358,12 @@ afsd_Main(DWORD argc, LPTSTR *argv)
 
         MountGlobalDrives();
 
+        code = afsd_InitDaemons(&reason);
+        if (code != 0) {
+            afsi_log("afsd_InitDaemons failed: %s (code = %d)", reason, code);
+                       osi_panic(reason, __FILE__, __LINE__);
+        }
+
 #ifndef NOTSERVICE
         if (bRunningAsService) {
             ServiceStatus.dwCurrentState = SERVICE_RUNNING;
@@ -1381,7 +1381,7 @@ afsd_Main(DWORD argc, LPTSTR *argv)
     }
 
     /* allow an exit to be called when started */
-    hHookDll = LoadLibrary(AFSD_HOOK_DLL);
+    hHookDll = cm_LoadAfsdHookLib();
     if (hHookDll)
     {
         BOOL hookRc = TRUE;
@@ -1426,7 +1426,7 @@ afsd_Main(DWORD argc, LPTSTR *argv)
        LogEvent(EVENTLOG_INFORMATION_TYPE, MSG_SERVICE_STOPPING);
 
     /* allow an exit to be called prior to stopping the service */
-    hHookDll = LoadLibrary(AFSD_HOOK_DLL);
+    hHookDll = cm_LoadAfsdHookLib();
     if (hHookDll)
     {
         BOOL hookRc = TRUE;
@@ -1448,29 +1448,26 @@ afsd_Main(DWORD argc, LPTSTR *argv)
     DismountGlobalDrives();
     afsi_log("Global Drives dismounted");
                                          
+    smb_Shutdown();                      
+    afsi_log("smb shutdown complete");   
+                                         
+    RpcShutdown();                       
+
+    cm_ReleaseAllLocks();
+
     cm_DaemonShutdown();                 
     afsi_log("Daemon shutdown complete");
     
-    afsd_ShutdownCM();
-
     buf_Shutdown();                      
     afsi_log("Buffer shutdown complete");
                                          
-    rx_Finalize();                       
-    afsi_log("rx finalization complete");
-                                         
-    smb_Shutdown();                      
-    afsi_log("smb shutdown complete");   
-                                         
-    RpcShutdown();                       
+    afsd_ShutdownCM();
 
-    cm_ReleaseAllLocks();
+    cm_ShutdownMappedMemory();           
 
     rx_Finalize();
     afsi_log("rx finalization complete");
 
-    cm_ShutdownMappedMemory();           
-
 #ifdef REGISTER_POWER_NOTIFICATIONS
     /* terminate thread used to flush cache */
     if (powerEventsRegistered)
@@ -1489,7 +1486,7 @@ afsd_Main(DWORD argc, LPTSTR *argv)
     cm_VolStatus_Finalize();
 
     /* allow an exit to be called after stopping the service */
-    hHookDll = LoadLibrary(AFSD_HOOK_DLL);
+    hHookDll = cm_LoadAfsdHookLib();
     if (hHookDll)
     {
         BOOL hookRc = TRUE;