standardise listen backlog

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@31455 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2010-10-01 09:22:52 +00:00
parent 8af7e6bf3a
commit 8c7b1d496a
7 changed files with 25 additions and 7 deletions

View file

@ -1,3 +1,13 @@
2010-10-01 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GSSocketStream.m:
* Source/NSSocketPort.m:
* Source/NSMessagePort.m:
* Source/win32/GSFileHandle.m:
* Source/GSNetwork.h:
* Source/GSFileHandle.m:
Standardise the backlog parameter to listen() calls.
2010-10-01 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSURL.m: Fix for bug #31153 ... allow hash in path when

View file

@ -39,6 +39,7 @@
#import "Foundation/NSByteOrder.h"
#import "Foundation/NSProcessInfo.h"
#import "Foundation/NSUserDefaults.h"
#import "GSNetwork.h"
#import "GSPrivate.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
@ -922,7 +923,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
/* We try to allow a large number of connections.
*/
if (listen(net, 10000) == -1)
if (listen(net, GSBACKLOG) == -1)
{
NSLog(@"unable to listen on port - %@", [NSError _last]);
(void) close(net);

View file

@ -74,6 +74,13 @@
#endif /* __MINGW__ */
/* The backlog argument to the listen() system call.
* Systems should silently truncate the backlog if they don't support one
* as large as we set, so it makes sense to set a large value in order to
* support high volume applications.
*/
#define GSBACKLOG 10000
#ifndef INADDRSZ
#define INADDRSZ 4
#endif

View file

@ -2444,8 +2444,6 @@ setNonBlocking(SOCKET fd)
return Nil;
}
#define SOCKET_BACKLOG 256
- (void) open
{
int bindReturn;
@ -2499,7 +2497,7 @@ setNonBlocking(SOCKET fd)
[self _sendEvent: NSStreamEventErrorOccurred];
return;
}
listenReturn = listen([self _sock], SOCKET_BACKLOG);
listenReturn = listen([self _sock], GSBACKLOG);
if (socketError(listenReturn))
{
[self _recordError];

View file

@ -44,6 +44,7 @@
#import "Foundation/NSFileManager.h"
#import "Foundation/NSProcessInfo.h"
#import "GSNetwork.h"
#import "GSPrivate.h"
#import "GSPortPrivate.h"
@ -1300,7 +1301,7 @@ typedef struct {
{
DESTROY(port);
}
else if (listen(desc, 128) < 0)
else if (listen(desc, GSBACKLOG) < 0)
{
NSLog(@"unable to listen on port - %@", [NSError _last]);
(void) close(desc);

View file

@ -1664,7 +1664,7 @@ static Class tcpPortClass;
(void) close(desc);
DESTROY(port);
}
else if (listen(desc, 128) == SOCKET_ERROR)
else if (listen(desc, GSBACKLOG) == SOCKET_ERROR)
{
NSLog(@"unable to listen on port - %@", [NSError _last]);
(void) close(desc);

View file

@ -43,6 +43,7 @@
#include "Foundation/NSDebug.h"
#include "../Tools/gdomap.h"
#include "../GSNetwork.h"
#include "../GSPrivate.h"
#include <winsock2.h>
@ -923,7 +924,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
return nil;
}
if (listen(net, 256) == SOCKET_ERROR)
if (listen(net, GSBACKLOG) == SOCKET_ERROR)
{
NSLog(@"unable to listen on port - %@", [NSError _last]);
(void) closesocket(net);