X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=support%2Fnfs%2Fsvc_socket.c;h=888c915931b000f42d86d026bc94e86ed8329139;hp=a3cb7ce2e1751dddedaf7e28ba63d4a8cf4d36c7;hb=11d34d11153df198103a57291937ea9ff8b7356e;hpb=db96d056578338dd1bb0371dc84638973c187ec6 diff --git a/support/nfs/svc_socket.c b/support/nfs/svc_socket.c index a3cb7ce..888c915 100644 --- a/support/nfs/svc_socket.c +++ b/support/nfs/svc_socket.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #ifdef _LIBC @@ -112,6 +113,26 @@ svc_socket (u_long number, int type, int protocol, int reuse) } } + if (sock >= 0 && protocol == IPPROTO_TCP) + { + /* Make the TCP rendezvous socket non-block to avoid + * problems with blocking in accept() after a spurious + * wakeup from the kernel */ + int flags; + if ((flags = fcntl(sock, F_GETFL)) < 0) + { + perror (_("svc_socket: can't get socket flags")); + (void) __close (sock); + sock = -1; + } + else if (fcntl(sock, F_SETFL, flags|O_NONBLOCK) < 0) + { + perror (_("svc_socket: can't set socket flags")); + (void) __close (sock); + sock = -1; + } + } + return sock; }