]> git.pld-linux.org Git - packages/rpcbind.git/blob - rpcbind-SO_REUSEADDR.patch
- rel 6
[packages/rpcbind.git] / rpcbind-SO_REUSEADDR.patch
1 commit 68556dc512493868960b367406e04d7169c003a8
2 Author: Jeff Layton <jlayton@redhat.com>
3 Date:   Tue Jun 22 17:33:14 2010 -0400
4
5     nd: set SO_REUSEADDR on NC_TPI_COTS listening sockets
6     
7     I previously sent this patch to the libtirpc-devel list but got no
8     response. Resending with wider distribution...
9     
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.
13     
14     Details of the problem are here:
15     
16         https://bugzilla.redhat.com/show_bug.cgi?id=597356
17     
18     Signed-off-by: Jeff Layton <jlayton@redhat.com>
19     Signed-off-by: Steve Dickson <steved@redhat.com>
20
21 diff --git a/src/rpcbind.c b/src/rpcbind.c
22 index ddf2cfc..c8f0d9f 100644
23 --- a/src/rpcbind.c
24 +++ b/src/rpcbind.c
25 @@ -276,6 +276,7 @@ init_transport(struct netconfig *nconf)
26         int addrlen = 0;
27         int nhostsbak;
28         int checkbind;
29 +       int on = 1;
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)
34                 }
35                 oldmask = umask(S_IXUSR|S_IXGRP|S_IXOTH);
36                 __rpc_fd2sockinfo(fd, &si);
37 +               if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on,
38 +                               sizeof(on)) != 0) {
39 +                       syslog(LOG_ERR, "cannot set SO_REUSEADDR on %s",
40 +                               nconf->nc_netid);
41 +                       if (res != NULL)
42 +                               freeaddrinfo(res);
43 +                       return 1;
44 +               }
45                 if (bind(fd, sa, addrlen) < 0) {
46                         syslog(LOG_ERR, "cannot bind %s: %m", nconf->nc_netid);
47                         if (res != NULL)
This page took 0.035824 seconds and 3 git commands to generate.