+Fri Feb 7 08:08:39 1997 Richard Basch <basch@lehman.com>
+
+ * cns.c (blocking_hook_proc): Additional logic is required to
+ prevent instantaneous timeouts when GetTickCount()
+ wraps every 49.7 days.
+
Sun Feb 2 11:22:57 1997 Richard Basch <basch@lehman.com>
* cns.c (k5_name_from_ccache):
BOOL beep;
static BOOL alerted; /* TRUE when user already alerted */
BOOL isblocking = FALSE; /* TRUE when blocked in WinSock */
+static DWORD blocking_timeout; /* Blocking timeout */
static DWORD blocking_end_time; /* Ending count for blocking timeout */
static FARPROC hook_instance; /* handle for blocking hook function */
*
* Returns: TRUE if we got and dispatched a message, FALSE otherwise.
*/
-BOOL CALLBACK
+BOOL __export CALLBACK
blocking_hook_proc(void)
{
MSG msg;
BOOL rc;
+ DWORD now;
- if (GetTickCount() > blocking_end_time) {
+ /*
+ * The additional timeout logic is required because GetTickCount will
+ * wrap approximately every 49.7 days.
+ */
+ now = GetTickCount();
+ if (now >= blocking_end_time &&
+ (blocking_end_time >= blocking_end_time - blocking_timeout ||
+ now < blocking_end_time - blocking_timeout)) {
WSACancelBlockingCall();
return FALSE;
}
return;
isblocking = TRUE;
- blocking_end_time = GetTickCount() + (1000 * timeout);
+ blocking_timeout = 1000 * timeout;
+ blocking_end_time = GetTickCount() + blocking_timeout;
#ifdef _WIN32
proc = WSASetBlockingHook(blocking_hook_proc);
#else