]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
Windows: afslogon start service if not started
authorJeffrey Altman <jaltman@your-file-system.com>
Tue, 26 Jul 2011 21:32:28 +0000 (17:32 -0400)
committerJeffrey Altman <jaltman@openafs.org>
Tue, 2 Aug 2011 15:02:03 +0000 (08:02 -0700)
If the service is configured for auto start but has yet
to start, kick it off just in case.

Reviewed-on: http://gerrit.openafs.org/5109
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Tested-by: Jeffrey Altman <jaltman@openafs.org>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
(cherry picked from a063ecdc78cf888df2459b32b0082d4767948563)

Change-Id: I8395230328385eb8d554cc85d2e659a3b7cacfb7
Reviewed-on: http://gerrit.openafs.org/5137
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Tested-by: Jeffrey Altman <jaltman@openafs.org>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
src/WINNT/afsd/afslogon.c

index 27d8a40b98ed668fd00f9d42bf085d92eb917add..9b09d346c809fef00387769e3e51f3d5a7352450 100644 (file)
@@ -312,6 +312,28 @@ BOOL IsServiceStartPending (void)
     return (Status.dwCurrentState == SERVICE_START_PENDING);
 }
 
+BOOL StartTheService (void)
+{
+    SC_HANDLE hManager;
+    DWORD gle = 0;
+
+    if ((hManager = OpenSCManager (NULL, NULL, GENERIC_READ|SERVICE_START)) != NULL)
+    {
+        SC_HANDLE hService;
+        if ((hService = OpenService (hManager, TEXT("TransarcAFSDaemon"), GENERIC_READ|SERVICE_START)) != NULL)
+        {
+            StartService (hService, 0, NULL);
+            gle = GetLastError();
+            CloseServiceHandle (hService);
+        } else
+            gle = GetLastError();
+
+        CloseServiceHandle (hManager);
+    }
+    DebugEvent("AFS AfsLogon - Service Start Return Code[0x%x]",gle);
+    return (gle == 0);
+}
+
 /* LOOKUPKEYCHAIN: macro to look up the value in the list of keys in order until it's found
    v:variable to receive value (reference type)
    t:type
@@ -931,8 +953,19 @@ DWORD APIENTRY NPLogonNotify(
 
     /* loop until AFS is started. */
     if (afsWillAutoStart) {
-       while (IsServiceRunning() || IsServiceStartPending()) {
-           DebugEvent("while(autostart) LogonOption[%x], Service AutoStart[%d]",
+        /*
+         * If the service is configured for auto start but hasn't started yet,
+         * give it a shove.
+         */
+        if (!(IsServiceRunning() || IsServiceStartPending()))
+            StartTheService();
+
+        while ( IsServiceStartPending() ) {
+            Sleep(10);
+        }
+
+       while (IsServiceRunning()) {
+            DebugEvent("while(autostart) LogonOption[%x], Service AutoStart[%d]",
                        opt.LogonOption,afsWillAutoStart);
 
            if (ISADREALM(opt.flags)) {