afsi_log("rx_SetMaxMTU %d successful", rx_mtu);
}
+ /* Open Microsoft Firewall to allow in port 7001 */
+ {
+ HKEY hk;
+ DWORD dwDisp;
+ TCHAR value = TEXT("7001:UDP:*:Enabled:AFS Cache Manager Callback");
+ if (RegCreateKeyEx (HKEY_LOCAL_MACHINE,
+ "SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile\GloballyOpenP",
+ 0, TEXT("container"), 0, KEY_SET_VALUE, NULL, &hk, &dwDisp) == ERROR_SUCCESS)
+ {
+ RegSetValueEx (hk, TEXT("7001:UDP"), NULL, REG_SZ, (PBYTE)value, sizeof(TCHAR) * (1+lstrlen(value)));
+ RegCloseKey (hk);
+ }
+ if (RegCreateKeyEx (HKEY_LOCAL_MACHINE,
+ "SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\GloballyOpenP",
+ 0, TEXT("container"), 0, KEY_SET_VALUE, NULL, &hk, &dwDisp) == ERROR_SUCCESS)
+ {
+ RegSetValueEx (hk, TEXT("7001:UDP"), NULL, REG_SZ, (PBYTE)value, sizeof(TCHAR) * (1+lstrlen(value)));
+ RegCloseKey (hk);
+ }
+ }
+
/* initialize RX, and tell it to listen to port 7001, which is used for
* callback RPC messages.
*/
extern void afsi_log(char *pattern, ...);
+HANDLE hAFSDMainThread = NULL;
+
HANDLE WaitToTerminate;
int GlobalStatus;
ServiceStatus.dwWin32ExitCode = NO_ERROR;
ServiceStatus.dwCheckPoint = 1;
ServiceStatus.dwWaitHint = 10000;
- ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_POWEREVENT;
+ ServiceStatus.dwControlsAccepted = 0;
SetServiceStatus(StatusHandle, &ServiceStatus);
SetEvent(WaitToTerminate);
dwRet = NO_ERROR;
{
long code;
char *reason;
+#ifdef JUMP
int jmpret;
+#endif /* JUMP */
HANDLE hInitHookDll;
AfsdInitHook initHook;
GlobalStatus = 0;
+ afsi_start();
+
WaitToTerminate = CreateEvent(NULL, TRUE, FALSE, TEXT("afsd_service_WaitToTerminate"));
if ( GetLastError() == ERROR_ALREADY_EXISTS )
afsi_log("Event Object Already Exists: %s", TEXT("afsd_service_WaitToTerminate"));
PowerNotificationThreadCreate();
#endif
- afsi_start();
-
/* allow an exit to be called prior to any initialization */
hInitHookDll = LoadLibrary(AFSD_HOOK_DLL);
if (hInitHookDll)
WaitForSingleObject(WaitToTerminate, INFINITE);
- ServiceStatus.dwCurrentState = SERVICE_STOP_PENDING;
- ServiceStatus.dwWin32ExitCode = NO_ERROR;
- ServiceStatus.dwCheckPoint = 0;
- ServiceStatus.dwWaitHint = 5000;
- ServiceStatus.dwControlsAccepted = 0;
- SetServiceStatus(StatusHandle, &ServiceStatus);
-
{
HANDLE h; char *ptbuf[1];
h = RegisterEventSource(NULL, AFS_DAEMON_EVENT_NAME);
/* Remove the ExceptionFilter */
SetUnhandledExceptionFilter(NULL);
- ServiceStatus.dwCurrentState = SERVICE_STOPPED;
+ if ( hInitHookDll )
+ FreeLibrary(hInitHookDll);
+
+ ServiceStatus.dwCurrentState = SERVICE_STOPPED;
ServiceStatus.dwWin32ExitCode = GlobalStatus ? ERROR_EXCEPTION_IN_SERVICE : NO_ERROR;
ServiceStatus.dwCheckPoint = 0;
ServiceStatus.dwWaitHint = 0;
if (status == ERROR_FAILED_SERVICE_CONTROLLER_CONNECT)
{
DWORD tid;
- CreateThread(NULL, 0, afsdMain_thread, 0, 0, &tid);
+ hAFSDMainThread = CreateThread(NULL, 0, afsdMain_thread, 0, 0, &tid);
printf("Hit <Enter> to terminate OpenAFS Client Service\n");
getchar();
SetEvent(WaitToTerminate);
}
}
+
+ if ( hAFSDMainThread ) {
+ WaitForSingleObject( hAFSDMainThread, INFINITE );
+ CloseHandle( hAFSDMainThread );
+ }
return(0);
}