mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Bugfix for DO handle lookup error.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@14541 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
7fa87a9b4b
commit
cdd609243e
3 changed files with 49 additions and 31 deletions
|
@ -1,3 +1,9 @@
|
|||
2002-09-24 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* 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 <rfm@gnu.org>
|
||||
|
||||
* Source/GSTcpHandle.m: ([-connectToPort:beforeDate:]) Added more
|
||||
|
|
|
@ -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);
|
||||
/*
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
#include <Foundation/NSString.h>
|
||||
#include <Foundation/NSData.h>
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/Foundation.h>
|
||||
|
||||
// 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, '[', ']', '{', '}', '\\', '^', '|', '~', '_' };
|
||||
|
|
Loading…
Reference in a new issue