windows-afsd-priority-class-20090401
authorJeffrey Altman <jaltman@secure-endpoints.com>
Wed, 1 Apr 2009 18:29:15 +0000 (18:29 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Wed, 1 Apr 2009 18:29:15 +0000 (18:29 +0000)
LICENSE MIT

Change the default priority class for afsd_service.exe to High.
This matches the priority class assigned to other system processes
that generate requests to afsd_service.exe.

Permit the ..\TransarcAFSDaemon\Parameters "PriorityClass"
registry value to be used to change the default.

src/WINNT/afsd/afsd_init.c

index d31233f..ec603a2 100644 (file)
@@ -617,6 +617,7 @@ int afsd_InitCM(char **reasonP)
     int cm_SubnetMask[CM_MAXINTERFACE_ADDR];/* client's subnet mask in host order*/
     int cm_NetMtu[CM_MAXINTERFACE_ADDR];    /* client's MTU sizes */
     int cm_NetFlags[CM_MAXINTERFACE_ADDR];  /* network flags */
+    DWORD dwPriority;
 
     WSAStartup(0x0101, &WSAjunk);
 
@@ -666,6 +667,16 @@ int afsd_InitCM(char **reasonP)
         osi_panic(buf, __FILE__, __LINE__);
     }
 
+    dummyLen = sizeof(dwPriority);
+    code = RegQueryValueEx(parmKey, "PriorityClass", NULL, NULL,
+                            (BYTE *) &dwPriority, &dummyLen);
+    if (code != ERROR_SUCCESS || dwPriority == 0) {
+        dwPriority = HIGH_PRIORITY_CLASS;
+    }
+    if (dwPriority != GetPriorityClass(GetCurrentProcess()))
+        SetPriorityClass(GetCurrentProcess(), dwPriority);
+    afsi_log("PriorityClass 0x%x", GetPriorityClass(GetCurrentProcess()));
+
     dummyLen = sizeof(lockOrderValidation);
     code = RegQueryValueEx(parmKey, "LockOrderValidation", NULL, NULL,
                             (BYTE *) &lockOrderValidation, &dummyLen);