static int powerEventsRegistered = 0;
extern int powerStateSuspended = 0;
+static VOID (WINAPI* pRtlCaptureContext)(PCONTEXT ContextRecord) = NULL;
+
/*
* Notifier function for use by osi_panic
*/
static void afsd_notifier(char *msgp, char *filep, long line)
{
+ CONTEXT context;
+
if (!msgp)
msgp = "unspecified assert";
afsd_ForceTrace(TRUE);
buf_ForceTrace(TRUE);
+ if (pRtlCaptureContext) {
+ pRtlCaptureContext(&context);
+ 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);
cm_DumpCells(afsi_file, "a", 0);
cm_DumpVolumes(afsi_file, "a", 0);
cm_DumpSCache(afsi_file, "a", 0);
-#ifdef keisa
- cm_dnlcDump(afsi_file, "a");
-#endif
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);
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 */
#endif /* JUMP */
HMODULE hHookDll;
HMODULE hAdvApi32;
+ HMODULE hKernel32;
#ifdef _DEBUG
void afsd_DbgBreakAllocInit();
osi_InitPanic(afsd_notifier);
osi_InitTraceOption();
+ hKernel32 = LoadLibrary("kernel32.dll");
+ if (hKernel32 == NULL)
+ {
+ afsi_log("Fatal: cannot load kernel32.dll");
+ return;
+ }
+ pRtlCaptureContext = GetProcAddress(hKernel32, "RtlCaptureContext");
+
GlobalStatus = 0;
afsi_start();
}
/* allow an exit to be called prior to any initialization */
- hHookDll = LoadLibrary(AFSD_HOOK_DLL);
+ hHookDll = cm_LoadAfsdHookLib();
if (hHookDll)
{
BOOL hookRc = TRUE;
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;
/* 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);
}
/* allow an exit to be called post smb initialization */
- hHookDll = LoadLibrary(AFSD_HOOK_DLL);
+ hHookDll = cm_LoadAfsdHookLib();
if (hHookDll)
{
BOOL hookRc = TRUE;
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;
}
/* allow an exit to be called when started */
- hHookDll = LoadLibrary(AFSD_HOOK_DLL);
+ hHookDll = cm_LoadAfsdHookLib();
if (hHookDll)
{
BOOL hookRc = TRUE;
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;
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)
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;