BOOL SetActionNotification (HWND hNotify, BOOL fSet) { BOOL rc = TRUE; size_t ii = 0; asc_Enter(); if (!fSet) { for (ii = 0; ii < l.chActionListeners; ++ii) { if (l.ahActionListeners[ ii ] == hNotify) l.ahActionListeners[ ii ] = NULL; } } else // (fSet) { for (ii = 0; ii < l.chActionListeners; ++ii) { if (l.ahActionListeners[ ii ] == NULL) break; } if (!REALLOC (l.ahActionListeners, l.chActionListeners, 1+ii, 1)) { rc = FALSE; } else { l.ahActionListeners[ ii ] = hNotify; } } asc_Leave(); return rc; }
void StartCallbackThread (void) { asc_Enter(); if ((++l.cReqCallback) == 1) { DWORD dwThreadID; l.hCallbackThread = CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE)ClientCallbackThread, (LPVOID)0, 0, &dwThreadID); } asc_Leave(); }
void StopPingThread (UINT_PTR idClient) { asc_Enter(); for (size_t ii = 0; ii < l.cdwClients; ++ii) { if (l.adwClients[ ii ] == idClient) l.adwClients[ ii ] = 0; } asc_Leave(); }
void StopCallbackThread (void) { asc_Enter(); if (!(l.cReqCallback) || !(--l.cReqCallback)) { if (l.hCallbackThread) { TerminateThread (l.hCallbackThread, 0); l.hCallbackThread = NULL; } } asc_Leave(); }
DWORD WINAPI ClientPingThread (LPVOID lp) { for (;;) { Sleep (csecAFSADMSVR_CLIENT_PING * 1000L); // server adds race allowance asc_Enter(); for (size_t ii = 0; ii < l.cdwClients; ++ii) { UINT_PTR idClient; if ((idClient = l.adwClients[ ii ]) == 0) continue; asc_Leave(); RpcTryExcept { ULONG status; if (!AfsAdmSvr_Ping (idClient, &status)) { if (status == ERROR_INVALID_HANDLE) // we've been disconnected! StopPingThread (idClient); } } RpcExcept(1) ; RpcEndExcept asc_Enter(); } asc_Leave(); } l.hPingThread = NULL; return 0; }
void NotifyActionListeners (LPASACTION pAction, BOOL fFinished) { asc_Enter(); for (size_t ii = 0; ii < l.chActionListeners; ++ii) { if (IsWindow (l.ahActionListeners[ ii ])) { LPASACTION pActionPost = New (ASACTION); memcpy (pActionPost, pAction, sizeof(ASACTION)); PostMessage (l.ahActionListeners[ ii ], WM_ASC_NOTIFY_ACTION, (WPARAM)fFinished, (LPARAM)pActionPost); } } asc_Leave(); }
void ClearObjectNotifications (HWND hNotify) { asc_Enter(); if (l.pListeners) { for (LPENUM pEnum = l.pListeners->FindFirst(); pEnum; pEnum = pEnum->FindNext()) { LPLISTENER pl = (LPLISTENER)( pEnum->GetObject() ); if (pl->hNotify == hNotify) { l.pListeners->Remove (pl); Delete (pl); } } } asc_Leave(); }
BOOL AddObjectNotification (HWND hNotify, ASID idCell, ASID idObject) { asc_Enter(); if (!l.pListeners) { l.pListeners = New (HASHLIST); l.pListenersKeyObject = l.pListeners->CreateKey (TEXT("idObject"), ListenersKeyObject_Compare, ListenersKeyObject_HashObject, ListenersKeyObject_HashData); } LPLISTENER pl = New (LISTENER); pl->idCell = idCell; pl->idObject = idObject; pl->hNotify = hNotify; l.pListeners->Add (pl); asc_Leave(); return TRUE; }
void StartPingThread (UINT_PTR idClient) { asc_Enter(); size_t ii; for (ii = 0; ii < l.cdwClients; ++ii) { if (!l.adwClients[ ii ]) break; } if (REALLOC (l.adwClients, l.cdwClients, 1+ii, 1)) { l.adwClients[ ii ] = idClient; } if (!l.hPingThread) { DWORD dwThreadID; l.hPingThread = CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE)ClientPingThread, (LPVOID)0, 0, &dwThreadID); } asc_Leave(); }
EXPORTED void ADMINAPI AfsAppLib_asc_Leave (void) { asc_Leave(); }