summaryrefslogtreecommitdiffstats
path: root/src/windows/cns
diff options
context:
space:
mode:
authorRichard Basch <probe@mit.edu>1997-02-07 13:55:01 +0000
committerRichard Basch <probe@mit.edu>1997-02-07 13:55:01 +0000
commit067bc3c815b0a870436fd3886d770cc66dea4abc (patch)
tree8a6e057580d3887311d58ca64d055b34d4ef64fc /src/windows/cns
parent06035540bf2f20df59df3f20541809b436400a68 (diff)
downloadkrb5-067bc3c815b0a870436fd3886d770cc66dea4abc.tar.gz
krb5-067bc3c815b0a870436fd3886d770cc66dea4abc.tar.xz
krb5-067bc3c815b0a870436fd3886d770cc66dea4abc.zip
cns.c:
Declare blocking_hook_proc with __export keyword so that it works with Win16. Win32 will only generate a warning message. Reworked timeout logic to accomodate the 49.7 day wraparound of GetTickCount() git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@9813 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/windows/cns')
-rw-r--r--src/windows/cns/ChangeLog6
-rw-r--r--src/windows/cns/cns.c16
2 files changed, 19 insertions, 3 deletions
diff --git a/src/windows/cns/ChangeLog b/src/windows/cns/ChangeLog
index 1fd2a5eec3..d07b3d5899 100644
--- a/src/windows/cns/ChangeLog
+++ b/src/windows/cns/ChangeLog
@@ -1,3 +1,9 @@
+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):
diff --git a/src/windows/cns/cns.c b/src/windows/cns/cns.c
index 021cc88abe..15e4554b04 100644
--- a/src/windows/cns/cns.c
+++ b/src/windows/cns/cns.c
@@ -55,6 +55,7 @@ BOOL alert; /* Actions on ticket expiration */
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 */
@@ -75,13 +76,21 @@ krb5_ccache k5_ccache;
*
* 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;
}
@@ -118,7 +127,8 @@ start_blocking_hook(int timeout)
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