* sendto_kdc.c (krb5int_cm_call_select): If timeout value has tv_sec==0, treat
authorKen Raeburn <raeburn@mit.edu>
Thu, 19 Sep 2002 19:49:16 +0000 (19:49 +0000)
committerKen Raeburn <raeburn@mit.edu>
Thu, 19 Sep 2002 19:49:16 +0000 (19:49 +0000)
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
src/lib/krb5/os/sendto_kdc.c

index a6b95422a007d37062842c2e45342789b5fe742a..a7a17ccc29c29641d3b6608caf8a868b61e3e1ae 100644 (file)
@@ -1,3 +1,9 @@
+2002-09-19  Ken Raeburn  <raeburn@mit.edu>
+
+       * 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  <raeburn@mit.edu>
 
        * sendto_kdc.c: Include cm.h.
index 09bbcaa8c4797403467d50320e5cab463a5d24eb..07d7a4d7bf0e470d55edeeddb1119bd094a5ccbe 100644 (file)
@@ -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;