diff options
author | mark mark@31f1291d-b8d6-0310-a050-a5561fc1590b <mark mark@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864> | 2008-08-21 17:20:03 +0000 |
---|---|---|
committer | mark mark@31f1291d-b8d6-0310-a050-a5561fc1590b <mark mark@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864> | 2008-08-21 17:20:03 +0000 |
commit | 0030f51a2deb9ec8549f76c2a20311ac4d4e1b23 (patch) | |
tree | 4b8a42a70d09ba616336b727c34b08354340961a /src | |
parent | 1f637024fcc5c0f67d6d01fdff7d6a95e7562f6a (diff) |
BUILD : 1.7.21 (1417) BUGS : NOTES : Set SO_REUSEADDR on sock to prevent potential issues with bind() failing after a restart
git-svn-id: svn://svn.anope.org/anope/trunk@1417 31f1291d-b8d6-0310-a050-a5561fc1590b
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1132 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src')
-rw-r--r-- | src/sockutil.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/sockutil.c b/src/sockutil.c index 9465e0877..b28989bdb 100644 --- a/src/sockutil.c +++ b/src/sockutil.c @@ -559,6 +559,7 @@ int conn(const char *host, int port, const char *lhost, int lport) #endif struct sockaddr_in sa, lsa; ano_socket_t sock; + int sockopt = 1; memset(&lsa, 0, sizeof(lsa)); if (lhost) { @@ -598,6 +599,11 @@ int conn(const char *host, int port, const char *lhost, int lport) if ((sock = socket(sa.sin_family, SOCK_STREAM, 0)) < 0) return -1; + if (setsockopt + (sock, SOL_SOCKET, SO_REUSEADDR, (char *) &sockopt, + sizeof(int)) < 0) + alog("debug: couldn't set SO_REUSEADDR on socket"); + if ((lhost || lport) && bind(sock, (struct sockaddr *) &lsa, sizeof(lsa)) < 0) { int errno_save = ano_sockgeterr(); |