From 08e8e4aa95784b44c8ce9c737a5bb64d5936d684 Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Thu, 19 Sep 2002 19:49:16 +0000 Subject: [PATCH] * sendto_kdc.c (krb5int_cm_call_select): If timeout value has tv_sec==0, treat it as meaning "no timeout". (krb5int_debug_fprint): Handle null timeval pointer. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@14884 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/os/ChangeLog | 6 ++++++ src/lib/krb5/os/sendto_kdc.c | 36 ++++++++++++++++++++++-------------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/lib/krb5/os/ChangeLog b/src/lib/krb5/os/ChangeLog index a6b95422a..a7a17ccc2 100644 --- a/src/lib/krb5/os/ChangeLog +++ b/src/lib/krb5/os/ChangeLog @@ -1,3 +1,9 @@ +2002-09-19 Ken Raeburn + + * sendto_kdc.c (krb5int_cm_call_select): If timeout value has + tv_sec==0, treat it as meaning "no timeout". + (krb5int_debug_fprint): Handle null timeval pointer. + 2002-09-18 Ken Raeburn * sendto_kdc.c: Include cm.h. diff --git a/src/lib/krb5/os/sendto_kdc.c b/src/lib/krb5/os/sendto_kdc.c index 09bbcaa8c..07d7a4d7b 100644 --- a/src/lib/krb5/os/sendto_kdc.c +++ b/src/lib/krb5/os/sendto_kdc.c @@ -171,9 +171,12 @@ krb5int_debug_fprint (const char *fmt, ...) case 't': /* %t => struct timeval * */ tv = va_arg(args, struct timeval *); - sprintf(tmpbuf, "%ld.%06ld", - (long) tv->tv_sec, (long) tv->tv_usec); - putstr(tmpbuf); + if (tv) { + sprintf(tmpbuf, "%ld.%06ld", + (long) tv->tv_sec, (long) tv->tv_usec); + putstr(tmpbuf); + } else + putstr("never"); break; case 'd': /* %d => int */ @@ -434,27 +437,32 @@ krb5_error_code krb5int_cm_call_select (const struct select_state *in, struct select_state *out, int *sret) { - struct timeval now; + struct timeval now, *timo; krb5_error_code e; *out = *in; e = getcurtime(&now); if (e) return e; - out->end_time.tv_sec -= now.tv_sec; - out->end_time.tv_usec -= now.tv_usec; - if (out->end_time.tv_usec < 0) { - out->end_time.tv_usec += 1000000; - out->end_time.tv_sec--; - } - if (out->end_time.tv_sec < 0) { - *sret = 0; - return 0; + if (out->end_time.tv_sec == 0) + timo = 0; + else { + timo = &out->end_time; + out->end_time.tv_sec -= now.tv_sec; + out->end_time.tv_usec -= now.tv_usec; + if (out->end_time.tv_usec < 0) { + out->end_time.tv_usec += 1000000; + out->end_time.tv_sec--; + } + if (out->end_time.tv_sec < 0) { + *sret = 0; + return 0; + } } dprint("selecting on max=%d sockets [%F] timeout %t\n", out->max, &out->rfds, &out->wfds, &out->xfds, out->max, - &out->end_time); + timo); *sret = select(out->max, &out->rfds, &out->wfds, &out->xfds, &out->end_time); e = SOCKET_ERRNO; -- 2.26.2