mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
networking portability for for solaris
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@33951 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
fde1cac9d3
commit
c0ddb7f5b9
7 changed files with 39 additions and 16 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
2011-10-08 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* GSFileHandle.m:
|
||||||
|
* GSNetwork.h:
|
||||||
|
* GSSocketStream.m:
|
||||||
|
* NSMessagePort.m:
|
||||||
|
* NSSocketPort.m:
|
||||||
|
* NSURLProtocol.m:
|
||||||
|
Check for EALREADY as well as EINPROGRESS as an indicator of an
|
||||||
|
incomplete system call on a non-blocking descriptor.
|
||||||
|
|
||||||
2011-10-07 Richard Frith-Macdonald <rfm@gnu.org>
|
2011-10-07 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/GSHTTPURLHandle.m:
|
* Source/GSHTTPURLHandle.m:
|
||||||
|
|
|
@ -910,7 +910,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
||||||
[self setNonBlocking: YES];
|
[self setNonBlocking: YES];
|
||||||
if (connect(net, &sin, GSPrivateSockaddrLength(&sin)) == -1)
|
if (connect(net, &sin, GSPrivateSockaddrLength(&sin)) == -1)
|
||||||
{
|
{
|
||||||
if (errno != EINPROGRESS)
|
if (!GSWOULDBLOCK)
|
||||||
{
|
{
|
||||||
NSLog(@"unable to make connection to %@ - %@",
|
NSLog(@"unable to make connection to %@ - %@",
|
||||||
GSPrivateSockaddrName(&sin), [NSError _last]);
|
GSPrivateSockaddrName(&sin), [NSError _last]);
|
||||||
|
|
|
@ -70,7 +70,7 @@
|
||||||
#define INVALID_SOCKET -1
|
#define INVALID_SOCKET -1
|
||||||
#define BADSOCKET(X) ((X) < 0)
|
#define BADSOCKET(X) ((X) < 0)
|
||||||
#define GSNETERROR errno
|
#define GSNETERROR errno
|
||||||
#define GSWOULDBLOCK (errno == EINPROGRESS)
|
#define GSWOULDBLOCK (errno == EINPROGRESS || errno == EALREADY)
|
||||||
|
|
||||||
#endif /* __MINGW__ */
|
#endif /* __MINGW__ */
|
||||||
|
|
||||||
|
|
|
@ -1246,12 +1246,7 @@ socketError(int result)
|
||||||
static inline BOOL
|
static inline BOOL
|
||||||
socketWouldBlock()
|
socketWouldBlock()
|
||||||
{
|
{
|
||||||
#if defined(__MINGW__)
|
return GSWOULDBLOCK ? YES : NO;
|
||||||
int e = WSAGetLastError();
|
|
||||||
return (e == WSAEWOULDBLOCK || e == WSAEINPROGRESS) ? YES : NO;
|
|
||||||
#else
|
|
||||||
return (errno == EWOULDBLOCK || errno == EINPROGRESS) ? YES : NO;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -381,7 +381,7 @@ static Class runLoopClass;
|
||||||
|
|
||||||
if (connect(desc, (struct sockaddr*)&sockAddr, SUN_LEN(&sockAddr)) < 0)
|
if (connect(desc, (struct sockaddr*)&sockAddr, SUN_LEN(&sockAddr)) < 0)
|
||||||
{
|
{
|
||||||
if (errno != EINPROGRESS)
|
if (!GSWOULDBLOCK)
|
||||||
{
|
{
|
||||||
NSLog(@"unable to make connection to %s - %@",
|
NSLog(@"unable to make connection to %s - %@",
|
||||||
sockAddr.sun_path, [NSError _last]);
|
sockAddr.sun_path, [NSError _last]);
|
||||||
|
|
|
@ -529,11 +529,7 @@ static Class runLoopClass;
|
||||||
if (connect(desc, (struct sockaddr*)&sockAddr,
|
if (connect(desc, (struct sockaddr*)&sockAddr,
|
||||||
GSPrivateSockaddrLength(&sockAddr)) == SOCKET_ERROR)
|
GSPrivateSockaddrLength(&sockAddr)) == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
#ifdef __MINGW__
|
if (!GSWOULDBLOCK)
|
||||||
if (WSAGetLastError() != WSAEWOULDBLOCK)
|
|
||||||
#else
|
|
||||||
if (errno != EINPROGRESS)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
NSLog(@"unable to make connection to %d - %@",
|
NSLog(@"unable to make connection to %d - %@",
|
||||||
GSPrivateSockaddrName(&sockAddr), [NSError _last]);
|
GSPrivateSockaddrName(&sockAddr), [NSError _last]);
|
||||||
|
|
|
@ -77,6 +77,7 @@ zfree(void *opaque, void *mem)
|
||||||
}
|
}
|
||||||
+ (void) purge: (NSNotification*)n;
|
+ (void) purge: (NSNotification*)n;
|
||||||
- (void) cache: (NSDate*)when;
|
- (void) cache: (NSDate*)when;
|
||||||
|
- (void) close;
|
||||||
- (NSDate*) expires;
|
- (NSDate*) expires;
|
||||||
- (id) initWithHost: (NSHost*)h port: (uint16_t)p forSSL: (BOOL)s;
|
- (id) initWithHost: (NSHost*)h port: (uint16_t)p forSSL: (BOOL)s;
|
||||||
- (NSInputStream*) inputStream;
|
- (NSInputStream*) inputStream;
|
||||||
|
@ -126,13 +127,28 @@ static NSLock *pairLock = nil;
|
||||||
|
|
||||||
- (void) cache: (NSDate*)when
|
- (void) cache: (NSDate*)when
|
||||||
{
|
{
|
||||||
ASSIGN(expires, when);
|
NSTimeInterval ti = [when timeIntervalSinceNow];
|
||||||
|
|
||||||
|
if (ti <= 0.0)
|
||||||
|
{
|
||||||
|
[self close];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
NSAssert(ip != nil, NSGenericException);
|
||||||
|
if (ti > 120.0)
|
||||||
|
{
|
||||||
|
ASSIGN(expires, [NSDate dateWithTimeIntervalSinceNow: 120.0]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ASSIGN(expires, when);
|
||||||
|
}
|
||||||
[pairLock lock];
|
[pairLock lock];
|
||||||
[pairCache addObject: self];
|
[pairCache addObject: self];
|
||||||
[pairLock unlock];
|
[pairLock unlock];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) close
|
||||||
{
|
{
|
||||||
[ip setDelegate: nil];
|
[ip setDelegate: nil];
|
||||||
[op setDelegate: nil];
|
[op setDelegate: nil];
|
||||||
|
@ -144,6 +160,11 @@ static NSLock *pairLock = nil;
|
||||||
[op close];
|
[op close];
|
||||||
DESTROY(ip);
|
DESTROY(ip);
|
||||||
DESTROY(op);
|
DESTROY(op);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) dealloc
|
||||||
|
{
|
||||||
|
[self close];
|
||||||
DESTROY(host);
|
DESTROY(host);
|
||||||
DESTROY(expires);
|
DESTROY(expires);
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue