Commit fbda6650 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(isc_createtcp): Fixed calls to setsockopt with

	SO_LINGER and SO_REUSEADDR arguments.  The old-style style
	previously used should no longer be necessary on modern operating
	systems, and in fact it no longer works everywere.
(isc_listentcp): Clear errno on each loop in the retry loop.
parent 9bc5c5eb
......@@ -181,6 +181,8 @@ isc_createtcp(IscSessionConfig *cfg, int fd)
{
IscSession *scb;
int res;
int flag;
struct linger ling;
if (fd == -1)
......@@ -204,10 +206,18 @@ isc_createtcp(IscSessionConfig *cfg, int fd)
return NULL;
}
#ifdef SO_DONTLINGER
#if 0
/* The setsockopt calls below used to look like this, but this style is
apparently now obsolete. It doesn't work on some Linux boxes. */
setsockopt(fd, SOL_SOCKET, SO_DONTLINGER, 0, 0);
#endif
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, 0, 0);
#endif
ling.l_onoff = 0;
ling.l_linger = 0;
setsockopt(fd, SOL_SOCKET, SO_LINGER, &ling, sizeof(ling));
flag = 1;
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &flag, sizeof(flag));
scb = isc_create(cfg, &isc_tcp_funs);
if (!scb)
......@@ -338,10 +348,12 @@ isc_listentcp(IscMaster *mcb,
if (!scb)
return NULL;
errno = 0;
for (retries = 0; retries < scb->cfg->max.openretries; sleep(1), retries++)
{
errno = 0;
if (isc_bindtcp(scb, address, service) >= 0 || errno != EADDRINUSE)
break;
}
if (retries >= scb->cfg->max.openretries || errno != 0)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment