1 commit 68556dc512493868960b367406e04d7169c003a8
2 Author: Jeff Layton <jlayton@redhat.com>
3 Date: Tue Jun 22 17:33:14 2010 -0400
5 nd: set SO_REUSEADDR on NC_TPI_COTS listening sockets
7 I previously sent this patch to the libtirpc-devel list but got no
8 response. Resending with wider distribution...
10 If we don't set SO_REUSEADDR, then if there are any sockets on this port
11 in TIME_WAIT state when rpcbind is restarted then that will prevent the
12 bind() call from succeeding.
14 Details of the problem are here:
16 https://bugzilla.redhat.com/show_bug.cgi?id=597356
18 Signed-off-by: Jeff Layton <jlayton@redhat.com>
19 Signed-off-by: Steve Dickson <steved@redhat.com>
21 diff --git a/src/rpcbind.c b/src/rpcbind.c
22 index ddf2cfc..c8f0d9f 100644
25 @@ -276,6 +276,7 @@ init_transport(struct netconfig *nconf)
30 struct sockaddr *sa = NULL;
31 u_int32_t host_addr[4]; /* IPv4 or IPv6 */
32 struct sockaddr_un sun;
33 @@ -493,6 +494,14 @@ init_transport(struct netconfig *nconf)
35 oldmask = umask(S_IXUSR|S_IXGRP|S_IXOTH);
36 __rpc_fd2sockinfo(fd, &si);
37 + if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on,
39 + syslog(LOG_ERR, "cannot set SO_REUSEADDR on %s",
45 if (bind(fd, sa, addrlen) < 0) {
46 syslog(LOG_ERR, "cannot bind %s: %m", nconf->nc_netid);