2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include <afs/param.h>
27 #include <rx/rx_prototypes.h>
28 #include <WINNT/afsreg.h>
33 long cm_daemonCheckDownInterval = 180;
34 long cm_daemonCheckUpInterval = 240;
35 long cm_daemonCheckVolInterval = 3600;
36 long cm_daemonCheckCBInterval = 60;
37 long cm_daemonCheckVolCBInterval = 0;
38 long cm_daemonCheckLockInterval = 2;
39 long cm_daemonTokenCheckInterval = 180;
40 long cm_daemonCheckOfflineVolInterval = 600;
41 long cm_daemonPerformanceTuningInterval = 0;
42 long cm_daemonRankServerInterval = 600;
44 osi_rwlock_t cm_daemonLock;
46 long cm_bkgQueueCount; /* # of queued requests */
48 int cm_bkgWaitingForCount; /* true if someone's waiting for cm_bkgQueueCount to drop */
50 cm_bkgRequest_t *cm_bkgListp; /* first elt in the list of requests */
51 cm_bkgRequest_t *cm_bkgListEndp; /* last elt in the list of requests */
53 extern int powerStateSuspended;
54 int daemon_ShutdownFlag = 0;
55 static int cm_nDaemons = 0;
56 static time_t lastIPAddrChange = 0;
58 static EVENT_HANDLE cm_Daemon_ShutdownEvent = NULL;
59 static EVENT_HANDLE cm_LockDaemon_ShutdownEvent = NULL;
60 static EVENT_HANDLE cm_IPAddrDaemon_ShutdownEvent = NULL;
61 static EVENT_HANDLE cm_BkgDaemon_ShutdownEvent[CM_MAX_DAEMONS] =
62 {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};
64 void cm_IpAddrDaemon(long parm)
66 extern void smb_CheckVCs(void);
67 char * name = "cm_IPAddrDaemon_ShutdownEvent";
69 cm_IPAddrDaemon_ShutdownEvent = thrd_CreateEvent(NULL, FALSE, FALSE, name);
70 if ( GetLastError() == ERROR_ALREADY_EXISTS )
71 afsi_log("Event Object Already Exists: %s", name);
73 rx_StartClientThread();
75 while (daemon_ShutdownFlag == 0) {
78 thrd_SetEvent(cm_IPAddrDaemon_ShutdownEvent);
79 Result = NotifyAddrChange(NULL,NULL);
80 if (Result == NO_ERROR && daemon_ShutdownFlag == 0) {
81 lastIPAddrChange = osi_Time();
82 smb_SetLanAdapterChangeDetected();
83 cm_SetLanAdapterChangeDetected();
84 thrd_ResetEvent(cm_IPAddrDaemon_ShutdownEvent);
88 thrd_SetEvent(cm_IPAddrDaemon_ShutdownEvent);
91 void cm_BkgDaemon(void * parm)
96 long daemonID = (long)(LONG_PTR)parm;
98 snprintf(name, sizeof(name), "cm_BkgDaemon_ShutdownEvent%u", daemonID);
100 cm_BkgDaemon_ShutdownEvent[daemonID] = thrd_CreateEvent(NULL, FALSE, FALSE, name);
101 if ( GetLastError() == ERROR_ALREADY_EXISTS )
102 afsi_log("Event Object Already Exists: %s", name);
104 rx_StartClientThread();
106 lock_ObtainWrite(&cm_daemonLock);
107 while (daemon_ShutdownFlag == 0) {
108 if (powerStateSuspended) {
112 if (!cm_bkgListEndp) {
113 osi_SleepW((LONG_PTR)&cm_bkgListp, &cm_daemonLock);
114 lock_ObtainWrite(&cm_daemonLock);
118 /* we found a request */
119 for (rp = cm_bkgListEndp; rp; rp = (cm_bkgRequest_t *) osi_QPrev(&rp->q))
121 if (cm_ServerAvailable(&rp->scp->fid, rp->userp))
125 /* we couldn't find a request that we could process at the current time */
126 lock_ReleaseWrite(&cm_daemonLock);
128 lock_ObtainWrite(&cm_daemonLock);
132 osi_QRemoveHT((osi_queue_t **) &cm_bkgListp, (osi_queue_t **) &cm_bkgListEndp, &rp->q);
133 osi_assertx(cm_bkgQueueCount-- > 0, "cm_bkgQueueCount 0");
134 lock_ReleaseWrite(&cm_daemonLock);
136 osi_Log1(afsd_logp,"cm_BkgDaemon processing request 0x%p", rp);
138 #ifdef DEBUG_REFCOUNT
139 osi_Log2(afsd_logp,"cm_BkgDaemon (before) scp 0x%x ref %d",rp->scp, rp->scp->refCount);
141 code = (*rp->procp)(rp->scp, rp->p1, rp->p2, rp->p3, rp->p4, rp->userp);
142 #ifdef DEBUG_REFCOUNT
143 osi_Log2(afsd_logp,"cm_BkgDaemon (after) scp 0x%x ref %d",rp->scp, rp->scp->refCount);
147 * Keep the following list synchronized with the
148 * error code list in cm_BkgStore.
149 * cm_SyncOpDone(CM_SCACHESYNC_ASYNCSTORE) will be called there unless
150 * one of these errors has occurred.
153 case CM_ERROR_TIMEDOUT: /* or server restarting */
155 case CM_ERROR_WOULDBLOCK:
156 case CM_ERROR_ALLBUSY:
157 case CM_ERROR_ALLDOWN:
158 case CM_ERROR_ALLOFFLINE:
159 case CM_ERROR_PARTIALWRITE:
160 if (rp->procp == cm_BkgStore) {
162 "cm_BkgDaemon re-queueing failed request 0x%p code 0x%x",
164 lock_ObtainWrite(&cm_daemonLock);
166 osi_QAddT((osi_queue_t **) &cm_bkgListp, (osi_queue_t **)&cm_bkgListEndp, &rp->q);
168 } /* otherwise fall through */
169 case 0: /* success */
170 default: /* other error */
172 osi_Log1(afsd_logp,"cm_BkgDaemon SUCCESS: request 0x%p", rp);
174 osi_Log2(afsd_logp,"cm_BkgDaemon FAILED: request dropped 0x%p code 0x%x",
176 cm_ReleaseUser(rp->userp);
177 cm_ReleaseSCache(rp->scp);
179 lock_ObtainWrite(&cm_daemonLock);
182 lock_ReleaseWrite(&cm_daemonLock);
183 thrd_SetEvent(cm_BkgDaemon_ShutdownEvent[daemonID]);
186 void cm_QueueBKGRequest(cm_scache_t *scp, cm_bkgProc_t *procp, afs_uint32 p1, afs_uint32 p2, afs_uint32 p3, afs_uint32 p4,
191 rp = malloc(sizeof(*rp));
192 memset(rp, 0, sizeof(*rp));
204 lock_ObtainWrite(&cm_daemonLock);
206 osi_QAdd((osi_queue_t **) &cm_bkgListp, &rp->q);
209 lock_ReleaseWrite(&cm_daemonLock);
211 osi_Wakeup((LONG_PTR) &cm_bkgListp);
215 IsWindowsFirewallPresent(void)
220 BOOLEAN result = FALSE;
221 LPQUERY_SERVICE_CONFIG pConfig = NULL;
225 /* Open services manager */
226 scm = OpenSCManager(NULL, NULL, GENERIC_READ);
227 if (!scm) return FALSE;
229 /* Open Windows Firewall service */
230 svc = OpenService(scm, "MpsSvc", SERVICE_QUERY_CONFIG);
232 afsi_log("MpsSvc Service could not be opened for query: 0x%x", GetLastError());
233 svc = OpenService(scm, "SharedAccess", SERVICE_QUERY_CONFIG);
235 afsi_log("SharedAccess Service could not be opened for query: 0x%x", GetLastError());
240 /* Query Windows Firewall service config, first just to get buffer size */
241 /* Expected to fail, so don't test return value */
242 (void) QueryServiceConfig(svc, NULL, 0, &BufSize);
243 status = GetLastError();
244 if (status != ERROR_INSUFFICIENT_BUFFER)
247 /* Allocate buffer */
248 pConfig = (LPQUERY_SERVICE_CONFIG)GlobalAlloc(GMEM_FIXED,BufSize);
252 /* Query Windows Firewall service config, this time for real */
253 flag = QueryServiceConfig(svc, pConfig, BufSize, &BufSize);
255 afsi_log("QueryServiceConfig failed: 0x%x", GetLastError());
259 /* Is it autostart? */
260 afsi_log("AutoStart 0x%x", pConfig->dwStartType);
261 if (pConfig->dwStartType < SERVICE_DEMAND_START)
267 CloseServiceHandle(svc);
269 CloseServiceHandle(scm);
275 cm_DaemonCheckInit(void)
282 code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSREG_CLT_SVC_PARAM_SUBKEY,
283 0, KEY_QUERY_VALUE, &parmKey);
287 dummyLen = sizeof(DWORD);
288 code = RegQueryValueEx(parmKey, "daemonCheckDownInterval", NULL, NULL,
289 (BYTE *) &dummy, &dummyLen);
290 if (code == ERROR_SUCCESS && dummy)
291 cm_daemonCheckDownInterval = dummy;
292 afsi_log("daemonCheckDownInterval is %d", cm_daemonCheckDownInterval);
294 dummyLen = sizeof(DWORD);
295 code = RegQueryValueEx(parmKey, "daemonCheckUpInterval", NULL, NULL,
296 (BYTE *) &dummy, &dummyLen);
297 if (code == ERROR_SUCCESS && dummy)
298 cm_daemonCheckUpInterval = dummy;
299 afsi_log("daemonCheckUpInterval is %d", cm_daemonCheckUpInterval);
301 dummyLen = sizeof(DWORD);
302 code = RegQueryValueEx(parmKey, "daemonCheckVolInterval", NULL, NULL,
303 (BYTE *) &dummy, &dummyLen);
304 if (code == ERROR_SUCCESS && dummy)
305 cm_daemonCheckVolInterval = dummy;
306 afsi_log("daemonCheckVolInterval is %d", cm_daemonCheckVolInterval);
308 dummyLen = sizeof(DWORD);
309 code = RegQueryValueEx(parmKey, "daemonCheckCBInterval", NULL, NULL,
310 (BYTE *) &dummy, &dummyLen);
311 if (code == ERROR_SUCCESS && dummy)
312 cm_daemonCheckCBInterval = dummy;
313 afsi_log("daemonCheckCBInterval is %d", cm_daemonCheckCBInterval);
315 dummyLen = sizeof(DWORD);
316 code = RegQueryValueEx(parmKey, "daemonCheckVolCBInterval", NULL, NULL,
317 (BYTE *) &dummy, &dummyLen);
318 if (code == ERROR_SUCCESS && dummy)
319 cm_daemonCheckVolCBInterval = dummy;
320 afsi_log("daemonCheckVolCBInterval is %d", cm_daemonCheckVolCBInterval);
322 dummyLen = sizeof(DWORD);
323 code = RegQueryValueEx(parmKey, "daemonCheckLockInterval", NULL, NULL,
324 (BYTE *) &dummy, &dummyLen);
325 if (code == ERROR_SUCCESS && dummy)
326 cm_daemonCheckLockInterval = dummy;
327 afsi_log("daemonCheckLockInterval is %d", cm_daemonCheckLockInterval);
329 dummyLen = sizeof(DWORD);
330 code = RegQueryValueEx(parmKey, "daemonCheckTokenInterval", NULL, NULL,
331 (BYTE *) &dummy, &dummyLen);
332 if (code == ERROR_SUCCESS && dummy)
333 cm_daemonTokenCheckInterval = dummy;
334 afsi_log("daemonCheckTokenInterval is %d", cm_daemonTokenCheckInterval);
336 dummyLen = sizeof(DWORD);
337 code = RegQueryValueEx(parmKey, "daemonCheckOfflineVolInterval", NULL, NULL,
338 (BYTE *) &dummy, &dummyLen);
339 if (code == ERROR_SUCCESS && dummy)
340 cm_daemonCheckOfflineVolInterval = dummy;
341 afsi_log("daemonCheckOfflineVolInterval is %d", cm_daemonCheckOfflineVolInterval);
343 dummyLen = sizeof(DWORD);
344 code = RegQueryValueEx(parmKey, "daemonPerformanceTuningInterval", NULL, NULL,
345 (BYTE *) &dummy, &dummyLen);
346 if (code == ERROR_SUCCESS)
347 cm_daemonPerformanceTuningInterval = dummy;
348 afsi_log("daemonPerformanceTuningInterval is %d", cm_daemonPerformanceTuningInterval);
350 dummyLen = sizeof(DWORD);
351 code = RegQueryValueEx(parmKey, "daemonRankServerInterval", NULL, NULL,
352 (BYTE *) &dummy, &dummyLen);
353 if (code == ERROR_SUCCESS && dummy)
354 cm_daemonRankServerInterval = dummy;
355 afsi_log("daemonRankServerInterval is %d", cm_daemonRankServerInterval);
357 RegCloseKey(parmKey);
359 if (cm_daemonPerformanceTuningInterval)
360 cm_PerformanceTuningInit();
363 /* periodic lock check daemon */
364 void cm_LockDaemon(long parm)
367 time_t lastLockCheck;
368 char * name = "cm_LockDaemon_ShutdownEvent";
370 cm_LockDaemon_ShutdownEvent = thrd_CreateEvent(NULL, FALSE, FALSE, name);
371 if ( GetLastError() == ERROR_ALREADY_EXISTS )
372 afsi_log("Event Object Already Exists: %s", name);
375 lastLockCheck = now - cm_daemonCheckLockInterval/2 + (rand() % cm_daemonCheckLockInterval);
377 while (daemon_ShutdownFlag == 0) {
378 if (powerStateSuspended) {
385 if (now > lastLockCheck + cm_daemonCheckLockInterval &&
386 daemon_ShutdownFlag == 0 &&
387 powerStateSuspended == 0) {
390 if (daemon_ShutdownFlag == 1)
394 thrd_Sleep(1000); /* sleep 1 second */
396 thrd_SetEvent(cm_LockDaemon_ShutdownEvent);
399 /* periodic check daemon */
400 void cm_Daemon(long parm)
404 time_t lastCBExpirationCheck;
405 time_t lastVolCBRenewalCheck;
406 time_t lastDownServerCheck;
407 time_t lastUpServerCheck;
408 time_t lastTokenCacheCheck;
409 time_t lastBusyVolCheck;
410 time_t lastPerformanceCheck;
411 time_t lastServerRankCheck;
416 char * name = "cm_Daemon_ShutdownEvent";
417 int configureFirewall = IsWindowsFirewallPresent();
418 int bAddrChangeCheck = 0;
420 cm_Daemon_ShutdownEvent = thrd_CreateEvent(NULL, FALSE, FALSE, name);
421 if ( GetLastError() == ERROR_ALREADY_EXISTS )
422 afsi_log("Event Object Already Exists: %s", name);
424 if (!configureFirewall) {
425 afsi_log("No Windows Firewall detected");
428 if (cm_freelanceEnabled && cm_freelanceImportCellServDB)
429 cm_FreelanceImportCellServDB();
431 /* ping all file servers, up or down, with unauthenticated connection,
432 * to find out whether we have all our callbacks from the server still.
433 * Also, ping down VLDBs.
436 * Seed the random number generator with our own address, so that
437 * clients starting at the same time don't all do vol checks at the
440 gethostname(thostName, sizeof(thostName));
441 thp = gethostbyname(thostName);
442 if (thp == NULL) /* In djgpp, gethostname returns the netbios
443 name of the machine. gethostbyname will fail
444 looking this up if it differs from DNS name. */
447 memcpy(&code, thp->h_addr_list[0], 4);
451 cm_DaemonCheckInit();
454 lastVolCheck = now - cm_daemonCheckVolInterval/2 + (rand() % cm_daemonCheckVolInterval);
455 lastCBExpirationCheck = now - cm_daemonCheckCBInterval/2 + (rand() % cm_daemonCheckCBInterval);
456 if (cm_daemonCheckVolCBInterval)
457 lastVolCBRenewalCheck = now - cm_daemonCheckVolCBInterval/2 + (rand() % cm_daemonCheckVolCBInterval);
458 lastDownServerCheck = now - cm_daemonCheckDownInterval/2 + (rand() % cm_daemonCheckDownInterval);
459 lastUpServerCheck = now - cm_daemonCheckUpInterval/2 + (rand() % cm_daemonCheckUpInterval);
460 lastTokenCacheCheck = now - cm_daemonTokenCheckInterval/2 + (rand() % cm_daemonTokenCheckInterval);
461 lastBusyVolCheck = now - cm_daemonCheckOfflineVolInterval/2 * (rand() % cm_daemonCheckOfflineVolInterval);
462 if (cm_daemonPerformanceTuningInterval)
463 lastPerformanceCheck = now - cm_daemonPerformanceTuningInterval/2 * (rand() % cm_daemonPerformanceTuningInterval);
464 lastServerRankCheck = now - cm_daemonRankServerInterval/2 * (rand() % cm_daemonRankServerInterval);
466 while (daemon_ShutdownFlag == 0) {
467 if (powerStateSuspended) {
471 /* check to see if the listener threads halted due to network
472 * disconnect or other issues. If so, attempt to restart them.
474 smb_RestartListeners(0);
476 if (daemon_ShutdownFlag == 1)
479 if (configureFirewall) {
480 /* Open Microsoft Firewall to allow in port 7001 */
481 switch (icf_CheckAndAddAFSPorts(AFS_PORTSET_CLIENT)) {
483 afsi_log("Windows Firewall Configuration succeeded");
484 configureFirewall = 0;
487 afsi_log("Invalid Windows Firewall Port Set");
490 afsi_log("Unable to open Windows Firewall Profile");
493 afsi_log("Unable to create/modify Windows Firewall Port entries");
496 afsi_log("Unknown Windows Firewall Configuration error");
500 /* find out what time it is */
503 /* Determine whether an address change took place that we need to respond to */
504 if (bAddrChangeCheck)
505 bAddrChangeCheck = 0;
507 if (lastIPAddrChange != 0 && lastIPAddrChange + 2500 < now) {
508 bAddrChangeCheck = 1;
509 lastIPAddrChange = 0;
512 /* check down servers */
513 if ((bAddrChangeCheck || now > lastDownServerCheck + cm_daemonCheckDownInterval) &&
514 daemon_ShutdownFlag == 0 &&
515 powerStateSuspended == 0) {
516 lastDownServerCheck = now;
517 osi_Log0(afsd_logp, "cm_Daemon CheckDownServers");
518 cm_CheckServers(CM_FLAG_CHECKDOWNSERVERS, NULL);
519 if (daemon_ShutdownFlag == 1)
524 if (bAddrChangeCheck &&
525 daemon_ShutdownFlag == 0 &&
526 powerStateSuspended == 0) {
527 cm_ForceNewConnectionsAllServers();
530 /* check up servers */
531 if ((bAddrChangeCheck || now > lastUpServerCheck + cm_daemonCheckUpInterval) &&
532 daemon_ShutdownFlag == 0 &&
533 powerStateSuspended == 0) {
534 lastUpServerCheck = now;
535 osi_Log0(afsd_logp, "cm_Daemon CheckUpServers");
536 cm_CheckServers(CM_FLAG_CHECKUPSERVERS, NULL);
537 if (daemon_ShutdownFlag == 1)
542 if (bAddrChangeCheck &&
543 daemon_ShutdownFlag == 0 &&
544 powerStateSuspended == 0) {
546 cm_VolStatus_Network_Addr_Change();
550 * Once every five minutes inspect the volume list and enforce
551 * the volume location expiration time.
553 if (now > lastVolCheck + 300 &&
554 daemon_ShutdownFlag == 0 &&
555 powerStateSuspended == 0) {
557 cm_RefreshVolumes(cm_daemonCheckVolInterval);
558 if (daemon_ShutdownFlag == 1)
563 /* Rank all up servers */
564 if ((now > lastServerRankCheck + cm_daemonRankServerInterval) &&
565 daemon_ShutdownFlag == 0 &&
566 powerStateSuspended == 0) {
567 lastServerRankCheck = now;
568 osi_Log0(afsd_logp, "cm_Daemon RankServer");
570 if(daemon_ShutdownFlag == 1)
575 if (cm_daemonCheckVolCBInterval &&
576 now > lastVolCBRenewalCheck + cm_daemonCheckVolCBInterval &&
577 daemon_ShutdownFlag == 0 &&
578 powerStateSuspended == 0) {
579 lastVolCBRenewalCheck = now;
580 cm_VolumeRenewROCallbacks();
581 if (daemon_ShutdownFlag == 1)
586 if ((bAddrChangeCheck || now > lastBusyVolCheck + cm_daemonCheckOfflineVolInterval) &&
587 daemon_ShutdownFlag == 0 &&
588 powerStateSuspended == 0) {
589 lastBusyVolCheck = now;
590 cm_CheckOfflineVolumes();
591 if (daemon_ShutdownFlag == 1)
596 if (now > lastCBExpirationCheck + cm_daemonCheckCBInterval &&
597 daemon_ShutdownFlag == 0 &&
598 powerStateSuspended == 0) {
599 lastCBExpirationCheck = now;
600 cm_CheckCBExpiration();
601 if (daemon_ShutdownFlag == 1)
606 if (now > lastTokenCacheCheck + cm_daemonTokenCheckInterval &&
607 daemon_ShutdownFlag == 0 &&
608 powerStateSuspended == 0) {
609 lastTokenCacheCheck = now;
610 cm_CheckTokenCache(now);
611 if (daemon_ShutdownFlag == 1)
616 /* allow an exit to be called prior to stopping the service */
617 hHookDll = cm_LoadAfsdHookLib();
621 AfsdDaemonHook daemonHook = ( AfsdDaemonHook ) GetProcAddress(hHookDll, AFSD_DAEMON_HOOK);
624 hookRc = daemonHook();
626 FreeLibrary(hHookDll);
631 SetEvent(WaitToTerminate);
634 if (daemon_ShutdownFlag == 1) {
640 if (cm_daemonPerformanceTuningInterval &&
641 now > lastPerformanceCheck + cm_daemonPerformanceTuningInterval &&
642 daemon_ShutdownFlag == 0 &&
643 powerStateSuspended == 0) {
644 lastPerformanceCheck = now;
645 cm_PerformanceTuningCheck();
646 if (daemon_ShutdownFlag == 1)
652 * sleep .5 seconds. if the thread blocks for a long time
653 * we risk not being able to close the cache before Windows
654 * kills our process during system shutdown.
659 thrd_SetEvent(cm_Daemon_ShutdownEvent);
662 void cm_DaemonShutdown(void)
667 daemon_ShutdownFlag = 1;
668 osi_Wakeup((LONG_PTR) &cm_bkgListp);
670 /* wait for shutdown */
671 for ( i=0; i<cm_nDaemons; i++) {
672 if (cm_BkgDaemon_ShutdownEvent[i])
673 code = thrd_WaitForSingleObject_Event(cm_BkgDaemon_ShutdownEvent[i], INFINITE);
676 if (cm_Daemon_ShutdownEvent)
677 code = thrd_WaitForSingleObject_Event(cm_Daemon_ShutdownEvent, INFINITE);
679 if (cm_LockDaemon_ShutdownEvent)
680 code = thrd_WaitForSingleObject_Event(cm_LockDaemon_ShutdownEvent, INFINITE);
684 * Do not waste precious time waiting for the ipaddr daemon to shutdown.
685 * When it does it means we have lost our network connection and we need
686 * it during cache shutdown in order to notify the file servers that this
687 * client is giving up all callbacks.
689 if (cm_IPAddrDaemon_ShutdownEvent)
690 code = thrd_WaitForSingleObject_Event(cm_IPAddrDaemon_ShutdownEvent, INFINITE);
694 void cm_InitDaemon(int nDaemons)
696 static osi_once_t once;
701 cm_nDaemons = (nDaemons > CM_MAX_DAEMONS) ? CM_MAX_DAEMONS : nDaemons;
703 if (osi_Once(&once)) {
704 lock_InitializeRWLock(&cm_daemonLock, "cm_daemonLock",
705 LOCK_HIERARCHY_DAEMON_GLOBAL);
708 /* creating IP Address Change monitor daemon */
709 phandle = thrd_Create((SecurityAttrib) 0, 0,
710 (ThreadFunc) cm_IpAddrDaemon, 0, 0, &pid, "cm_IpAddrDaemon");
711 osi_assertx(phandle != NULL, "cm_IpAddrDaemon thread creation failure");
712 thrd_CloseHandle(phandle);
714 /* creating pinging daemon */
715 phandle = thrd_Create((SecurityAttrib) 0, 0,
716 (ThreadFunc) cm_Daemon, 0, 0, &pid, "cm_Daemon");
717 osi_assertx(phandle != NULL, "cm_Daemon thread creation failure");
718 thrd_CloseHandle(phandle);
720 phandle = thrd_Create((SecurityAttrib) 0, 0,
721 (ThreadFunc) cm_LockDaemon, 0, 0, &pid, "cm_LockDaemon");
722 osi_assertx(phandle != NULL, "cm_LockDaemon thread creation failure");
723 thrd_CloseHandle(phandle);
725 for(i=0; i < cm_nDaemons; i++) {
726 phandle = thrd_Create((SecurityAttrib) 0, 0,
727 (ThreadFunc) cm_BkgDaemon, (LPVOID)(LONG_PTR)i, 0, &pid,
729 osi_assertx(phandle != NULL, "cm_BkgDaemon thread creation failure");
730 thrd_CloseHandle(phandle);