mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-25 01:31:08 +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
cafea3d3da
commit
522357d2de
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>
|
2002-09-20 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/GSTcpHandle.m: ([-connectToPort:beforeDate:]) Added more
|
* Source/GSTcpHandle.m: ([-connectToPort:beforeDate:]) Added more
|
||||||
|
|
|
@ -1694,6 +1694,7 @@ static Class tcpPortClass;
|
||||||
{
|
{
|
||||||
NSMapEnumerator me;
|
NSMapEnumerator me;
|
||||||
int sock;
|
int sock;
|
||||||
|
int opt = 1;
|
||||||
GSTcpHandle *handle = nil;
|
GSTcpHandle *handle = nil;
|
||||||
|
|
||||||
DO_LOCK(myLock);
|
DO_LOCK(myLock);
|
||||||
|
@ -1711,37 +1712,37 @@ static Class tcpPortClass;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NSEndMapTableEnumeration(&me);
|
NSEndMapTableEnumeration(&me);
|
||||||
if (handle == nil)
|
|
||||||
{
|
|
||||||
int opt = 1;
|
|
||||||
|
|
||||||
if ((sock = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) < 0)
|
/*
|
||||||
{
|
* Not found ... create a new handle.
|
||||||
NSLog(@"unable to create socket - %s", GSLastErrorStr(errno));
|
*/
|
||||||
}
|
handle = nil;
|
||||||
|
if ((sock = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) < 0)
|
||||||
|
{
|
||||||
|
NSLog(@"unable to create socket - %s", GSLastErrorStr(errno));
|
||||||
|
}
|
||||||
#ifndef BROKEN_SO_REUSEADDR
|
#ifndef BROKEN_SO_REUSEADDR
|
||||||
/*
|
/*
|
||||||
* Under decent systems, SO_REUSEADDR means that the port can be reused
|
* Under decent systems, SO_REUSEADDR means that the port can be reused
|
||||||
* immediately that this process exits. Under some it means
|
* immediately that this process exits. Under some it means
|
||||||
* that multiple processes can serve the same port simultaneously.
|
* that multiple processes can serve the same port simultaneously.
|
||||||
* We don't want that broken behavior!
|
* We don't want that broken behavior!
|
||||||
*/
|
*/
|
||||||
else if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char*)&opt,
|
else if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char*)&opt,
|
||||||
sizeof(opt)) < 0)
|
sizeof(opt)) < 0)
|
||||||
{
|
{
|
||||||
(void)close(sock);
|
(void)close(sock);
|
||||||
NSLog(@"unable to set reuse on socket - %s", GSLastErrorStr(errno));
|
NSLog(@"unable to set reuse on socket - %s", GSLastErrorStr(errno));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else if ((handle = [GSTcpHandle handleWithDescriptor: sock]) == nil)
|
else if ((handle = [GSTcpHandle handleWithDescriptor: sock]) == nil)
|
||||||
{
|
{
|
||||||
(void)close(sock);
|
(void)close(sock);
|
||||||
NSLog(@"unable to create GSTcpHandle - %s", GSLastErrorStr(errno));
|
NSLog(@"unable to create GSTcpHandle - %s", GSLastErrorStr(errno));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[recvPort addHandle: handle forSend: NO];
|
[recvPort addHandle: handle forSend: NO];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
DO_UNLOCK(myLock);
|
DO_UNLOCK(myLock);
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
#include <Foundation/NSString.h>
|
#include <Foundation/Foundation.h>
|
||||||
#include <Foundation/NSData.h>
|
|
||||||
#include <Foundation/NSException.h>
|
|
||||||
|
|
||||||
// Fri Oct 23 02:58:47 MET DST 1998 dave@turbocat.de
|
// Fri Oct 23 02:58:47 MET DST 1998 dave@turbocat.de
|
||||||
// cStringNoCopy -> cString
|
// cStringNoCopy -> cString
|
||||||
|
@ -35,6 +33,19 @@ int main()
|
||||||
NSMutableString *f1 = [NSMutableString stringWithString: @"ab"];
|
NSMutableString *f1 = [NSMutableString stringWithString: @"ab"];
|
||||||
NSStringEncoding *encs;
|
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
|
#if 0
|
||||||
{ // GSM test
|
{ // GSM test
|
||||||
unichar buf[] = { 163, '[', ']', '{', '}', '\\', '^', '|', '~', '_' };
|
unichar buf[] = { 163, '[', ']', '{', '}', '\\', '^', '|', '~', '_' };
|
||||||
|
|
Loading…
Reference in a new issue