From: Jeffrey Altman Date: Wed, 20 Jul 2011 18:21:09 +0000 (-0400) Subject: Windows: improve shutdown time X-Git-Tag: openafs-devel-1_7_1~249 X-Git-Url: https://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=d3a4b6ce700509383849653fa061a87298e5258f Windows: improve shutdown time During Windows OS shutdown the service may be given as little as six seconds to shut itself down before it will be terminated. Forced termination will leave the cache file in a dirty state. This patchset makes several minor changes to reduce the overall time required for shutdown: 1. do not wait for the IP address change notification thread. by the time it terminates the ip address has been lost. 2. send give up all callbacks earlier. 3. reorder the daemon thread waits. 4. change the daemon thread loop sleep time to 500ms in order to prevent the service from waiting up to 10 seconds for the thread to notice a shutdown is in progress. Change-Id: Ib1ff3eaf2e5116d9b3d7561670b8266e1bc5d1cf Reviewed-on: http://gerrit.openafs.org/5055 Reviewed-by: Derrick Brashear Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman --- diff --git a/src/WINNT/afsd/cm_daemon.c b/src/WINNT/afsd/cm_daemon.c index 59f1ae4..6de9b0c 100644 --- a/src/WINNT/afsd/cm_daemon.c +++ b/src/WINNT/afsd/cm_daemon.c @@ -524,8 +524,9 @@ void cm_Daemon(long parm) if (bAddrChangeCheck && daemon_ShutdownFlag == 0 && - powerStateSuspended == 0) + powerStateSuspended == 0) { cm_ForceNewConnectionsAllServers(); + } /* check up servers */ if ((bAddrChangeCheck || now > lastUpServerCheck + cm_daemonCheckUpInterval) && @@ -648,8 +649,14 @@ void cm_Daemon(long parm) now = osi_Time(); } - thrd_Sleep(10000); /* sleep 10 seconds */ + /* + * sleep .5 seconds. if the thread blocks for a long time + * we risk not being able to close the cache before Windows + * kills our process during system shutdown. + */ + thrd_Sleep(500); } + thrd_SetEvent(cm_Daemon_ShutdownEvent); } @@ -662,19 +669,27 @@ void cm_DaemonShutdown(void) osi_Wakeup((LONG_PTR) &cm_bkgListp); /* wait for shutdown */ + for ( i=0; i