mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 09:04:13 +00:00
Added broken reuseaddr checks.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@13487 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
314e0be563
commit
45ebb23d43
4 changed files with 45 additions and 36 deletions
|
@ -4,6 +4,9 @@
|
|||
* configure.in: test for broken SO_REUSEADDR
|
||||
* acconfig.h: Add BROKEN_SO_REUSEADDR
|
||||
* configure: regenerated
|
||||
* Source/UnixFileHandle.m: Use reuseaddr info.
|
||||
* Source/GSTcpPort.m: Use reuseaddr info.
|
||||
* Tools/gdomap.c: Use reuseaddr info.
|
||||
* Source/NSPortNameServer.m: Improved warnings about launching
|
||||
gdomap.
|
||||
* Source/NSDistributedNotification.m: Improved warnings about
|
||||
|
|
|
@ -1461,13 +1461,13 @@ static Class tcpPortClass;
|
|||
NSLog(@"unable to create socket - %s", GSLastErrorStr(errno));
|
||||
DESTROY(port);
|
||||
}
|
||||
#ifndef __MINGW__
|
||||
/*
|
||||
* Under unix, SO_REUSEADDR means that the port can be reused
|
||||
* immediately that this porcess exits. Under windoze it means
|
||||
* that multiple processes can serve the same port simultaneously.
|
||||
* We don't want that windows behavior!
|
||||
*/
|
||||
#ifndef BROKEN_SO_REUSEADDR
|
||||
/*
|
||||
* Under decent systems, SO_REUSEADDR means that the port can be
|
||||
* reused immediately that this porcess exits. Under some it means
|
||||
* that multiple processes can serve the same port simultaneously.
|
||||
* We don't want that broken behavior!
|
||||
*/
|
||||
else if (setsockopt(desc, SOL_SOCKET, SO_REUSEADDR, (char*)&reuse,
|
||||
sizeof(reuse)) < 0)
|
||||
{
|
||||
|
@ -1686,12 +1686,12 @@ static Class tcpPortClass;
|
|||
{
|
||||
NSLog(@"unable to create socket - %s", GSLastErrorStr(errno));
|
||||
}
|
||||
#ifndef __MINGW__
|
||||
#ifndef BROKEN_SO_REUSEADDR
|
||||
/*
|
||||
* Under unix, SO_REUSEADDR means that the port can be reused
|
||||
* immediately that this porcess exits. Under windoze it means
|
||||
* Under decent systems, SO_REUSEADDR means that the port can be reused
|
||||
* immediately that this process exits. Under some it means
|
||||
* that multiple processes can serve the same port simultaneously.
|
||||
* We don't want that windows behavior!
|
||||
* We don't want that broken behavior!
|
||||
*/
|
||||
else if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char*)&opt,
|
||||
sizeof(opt)) < 0)
|
||||
|
|
|
@ -384,7 +384,15 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin)
|
|||
return nil;
|
||||
}
|
||||
|
||||
#ifndef BROKEN_SO_REUSEADDR
|
||||
/*
|
||||
* Under decent systems, SO_REUSEADDR means that the port can be reused
|
||||
* immediately that this process exits. Under some it means
|
||||
* that multiple processes can serve the same port simultaneously.
|
||||
* We don't want that broken behavior!
|
||||
*/
|
||||
setsockopt(net, SOL_SOCKET, SO_REUSEADDR, (char *)&status, sizeof(status));
|
||||
#endif
|
||||
|
||||
if (bind(net, (struct sockaddr *)&sin, sizeof(sin)) < 0)
|
||||
{
|
||||
|
|
|
@ -1651,12 +1651,12 @@ init_ports()
|
|||
sprintf(ebuf, "Opened UDP socket %d", udp_desc);
|
||||
gdomap_log(LOG_DEBUG);
|
||||
}
|
||||
#ifndef __MINGW__
|
||||
#ifndef BROKEN_SO_REUSEADDR
|
||||
/*
|
||||
* Under windoze, REUSEADDR means something different from under unix.
|
||||
* It lets multiple processes bind to the same port at once -
|
||||
* which we don't want. So we only set it under unix (to allow a process to
|
||||
* bind to the same port immediately after one which was using the port exits.
|
||||
* Under decent systems, SO_REUSEADDR means that the port can be reused
|
||||
* immediately that this process exits. Under some it means
|
||||
* that multiple processes can serve the same port simultaneously.
|
||||
* We don't want that broken behavior!
|
||||
*/
|
||||
r = 1;
|
||||
if ((setsockopt(udp_desc,SOL_SOCKET,SO_REUSEADDR,(char*)&r,sizeof(r)))<0)
|
||||
|
@ -1744,12 +1744,12 @@ init_ports()
|
|||
sprintf(ebuf, "Opened TDP socket %d", tcp_desc);
|
||||
gdomap_log(LOG_DEBUG);
|
||||
}
|
||||
#ifndef __MINGW__
|
||||
#ifndef BROKEN_SO_REUSEADDR
|
||||
/*
|
||||
* Under windoze, REUSEADDR means something different from under unix.
|
||||
* It lets multiple processes bind to the same port at once -
|
||||
* which we don't want. So we only set it under unix (to allow a process to
|
||||
* bind to the same port immediately after one which was using the port exits.
|
||||
* Under decent systems, SO_REUSEADDR means that the port can be reused
|
||||
* immediately that this process exits. Under some it means
|
||||
* that multiple processes can serve the same port simultaneously.
|
||||
* We don't want that broken behavior!
|
||||
*/
|
||||
r = 1;
|
||||
if ((setsockopt(tcp_desc,SOL_SOCKET,SO_REUSEADDR,(char*)&r,sizeof(r)))<0)
|
||||
|
@ -2645,19 +2645,18 @@ handle_request(int desc)
|
|||
}
|
||||
else
|
||||
{
|
||||
#ifndef __MINGW__
|
||||
#ifndef BROKEN_SO_REUSEADDR
|
||||
int r = 1;
|
||||
|
||||
/*
|
||||
* Under windoze, REUSEADDR means something different from
|
||||
* under unix.
|
||||
* It lets multiple processes bind to the same port at once -
|
||||
* which we don't want. So we only set it under unix (to allow
|
||||
* a process to bind to the same port immediately after one
|
||||
* which was using the port exits.
|
||||
* Under decent systems, SO_REUSEADDR means that the port can
|
||||
* be reused immediately that this process exits. Under some
|
||||
* it means that multiple processes can serve the same port
|
||||
* simultaneously.
|
||||
* We don't want that broken behavior!
|
||||
*/
|
||||
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
|
||||
(char*)&r, sizeof(r)) < 0)
|
||||
(char*)&r, sizeof(r)) < 0)
|
||||
{
|
||||
perror("unable to set socket options");
|
||||
}
|
||||
|
@ -2747,16 +2746,15 @@ handle_request(int desc)
|
|||
}
|
||||
else
|
||||
{
|
||||
#ifndef __MINGW__
|
||||
#ifndef BROKEN_SO_REUSEADDR
|
||||
int r = 1;
|
||||
|
||||
/*
|
||||
* Under windoze, REUSEADDR means something different from
|
||||
* under unix.
|
||||
* It lets multiple processes bind to the same port at once -
|
||||
* which we don't want. So we only set it under unix (to allow
|
||||
* a process to bind to the same port immediately after one
|
||||
* which was using the port exits.
|
||||
* Under decent systems, SO_REUSEADDR means that the port can
|
||||
* be reused immediately that this process exits. Under some
|
||||
* it means that multiple processes can serve the same port
|
||||
* simultaneously.
|
||||
* We don't want that broken behavior!
|
||||
*/
|
||||
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
|
||||
(char*)&r, sizeof(r)) < 0)
|
||||
|
|
Loading…
Reference in a new issue