svn rev #25048: trunk/src/lib/krb5/os/

ghudson@MIT.EDU ghudson at MIT.EDU
Mon Jul 25 12:00:07 EDT 2011


http://src.mit.edu/fisheye/changelog/krb5/?cs=25048
Commit By: ghudson
Log Message:
ticket: 6933

In rare circumstances, such as checksum errors, some network stacks
can flag an fd for reading in select() and still block when the fd is
read.  Set all sockets non-blocking to prevent hangs when this occurs.
(We don't actually handle the resulting EWOULDBLOCK or EAGAIN errors,
so the rare cases will appear as communication failures and we will
close the socket.  This is already the case for TCP sockets and
probably isn't a big deal.)



Changed Files:
U   trunk/src/lib/krb5/os/sendto_kdc.c
Modified: trunk/src/lib/krb5/os/sendto_kdc.c
===================================================================
--- trunk/src/lib/krb5/os/sendto_kdc.c	2011-07-25 15:54:39 UTC (rev 25047)
+++ trunk/src/lib/krb5/os/sendto_kdc.c	2011-07-25 16:00:06 UTC (rev 25048)
@@ -758,6 +758,8 @@
 {
     int fd, e;
     unsigned int ssflags;
+    static const int one = 1;
+    static const struct linger lopt = { 0, 0 };
 
     dprint("start_connection(@%p)\ngetting %s socket in family %d...", state,
            state->socktype == SOCK_STREAM ? "stream" : "dgram", state->family);
@@ -769,12 +771,9 @@
     }
     set_cloexec_fd(fd);
     /* Make it non-blocking.  */
+    if (ioctlsocket(fd, FIONBIO, (const void *) &one))
+        dperror("sendto_kdc: ioctl(FIONBIO)");
     if (state->socktype == SOCK_STREAM) {
-        static const int one = 1;
-        static const struct linger lopt = { 0, 0 };
-
-        if (ioctlsocket(fd, FIONBIO, (const void *) &one))
-            dperror("sendto_kdc: ioctl(FIONBIO)");
         if (setsockopt(fd, SOL_SOCKET, SO_LINGER, &lopt, sizeof(lopt)))
             dperror("sendto_kdc: setsockopt(SO_LINGER)");
         TRACE_SENDTO_KDC_TCP_CONNECT(context, state);




More information about the cvs-krb5 mailing list