diff --git a/ChangeLog b/ChangeLog index 24e00e9c6..5abbd91cc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2002-09-24 Richard Frith-Macdonald + + * Source/GSTcpHandle.m: ([-handleForPort:beforeDate:]) fix bug where + we could end up using the last (non-matching) handle rather than + creating a new one. + 2002-09-20 Richard Frith-Macdonald * Source/GSTcpHandle.m: ([-connectToPort:beforeDate:]) Added more diff --git a/Source/GSTcpPort.m b/Source/GSTcpPort.m index aee8c7631..fca7c3a48 100644 --- a/Source/GSTcpPort.m +++ b/Source/GSTcpPort.m @@ -1694,6 +1694,7 @@ static Class tcpPortClass; { NSMapEnumerator me; int sock; + int opt = 1; GSTcpHandle *handle = nil; DO_LOCK(myLock); @@ -1711,37 +1712,37 @@ static Class tcpPortClass; } } NSEndMapTableEnumeration(&me); - if (handle == nil) - { - int opt = 1; - if ((sock = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) < 0) - { - NSLog(@"unable to create socket - %s", GSLastErrorStr(errno)); - } + /* + * Not found ... create a new handle. + */ + handle = nil; + if ((sock = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) < 0) + { + NSLog(@"unable to create socket - %s", GSLastErrorStr(errno)); + } #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! - */ - else if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char*)&opt, - sizeof(opt)) < 0) - { - (void)close(sock); - NSLog(@"unable to set reuse on socket - %s", GSLastErrorStr(errno)); - } + /* + * 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! + */ + else if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char*)&opt, + sizeof(opt)) < 0) + { + (void)close(sock); + NSLog(@"unable to set reuse on socket - %s", GSLastErrorStr(errno)); + } #endif - else if ((handle = [GSTcpHandle handleWithDescriptor: sock]) == nil) - { - (void)close(sock); - NSLog(@"unable to create GSTcpHandle - %s", GSLastErrorStr(errno)); - } - else - { - [recvPort addHandle: handle forSend: NO]; - } + else if ((handle = [GSTcpHandle handleWithDescriptor: sock]) == nil) + { + (void)close(sock); + NSLog(@"unable to create GSTcpHandle - %s", GSLastErrorStr(errno)); + } + else + { + [recvPort addHandle: handle forSend: NO]; } DO_UNLOCK(myLock); /* diff --git a/Testing/string.m b/Testing/string.m index 17c8a0834..e60f3245b 100644 --- a/Testing/string.m +++ b/Testing/string.m @@ -1,6 +1,4 @@ -#include -#include -#include +#include // Fri Oct 23 02:58:47 MET DST 1998 dave@turbocat.de // cStringNoCopy -> cString @@ -35,6 +33,19 @@ int main() NSMutableString *f1 = [NSMutableString stringWithString: @"ab"]; NSStringEncoding *encs; +{ + NSURL *currentURL; + NSData *data; + + currentURL = [NSURL URLWithString: + @"http:/www.foobar.org/PageWithAValid.plist"]; + data = [currentURL resourceDataUsingCache: NO]; + + if( data ) + printf(" YES \n"); + printf(" NO\n"); + exit(0); +} #if 0 { // GSM test unichar buf[] = { 163, '[', ']', '{', '}', '\\', '^', '|', '~', '_' };