fix some problems with the way socket fileDescriptors are treated

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/branches/nsxml_using_libxml2@34736 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Doug Simons 2012-02-07 19:22:39 +00:00
parent 576a1c2915
commit dc1f08597a
2 changed files with 18 additions and 1 deletions

View file

@ -1,3 +1,8 @@
2012-02-07 Doug Simons <doug.simons@testplant.com>
* Source/win32/GSFileHandle.m: Fix some problems with the way socket
fileDescriptors are treated.
2012-02-07 Doug Simons <doug.simons@testplant.com>
* Source/NSXMLNode.m: Changed dealloc to call xmlFreeNode() or

View file

@ -1104,6 +1104,13 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
- (id) initWithFileDescriptor: (int)desc closeOnDealloc: (BOOL)flag
{
// first test to see whether desc is a socket descriptor
unsigned long dummy;
if (ioctlsocket((SOCKET)desc, FIONREAD, &dummy) != SOCKET_ERROR)
{
desc = _open_osfhandle((SOCKET)desc, 0);
}
self = [super init];
if (self != nil)
{
@ -1267,6 +1274,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
- (int) fileDescriptor
{
if (isSocket)
return _get_osfhandle(descriptor);
return descriptor;
}
@ -1614,7 +1623,10 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
WSACloseEvent(event);
event = WSA_INVALID_EVENT;
}
(void)close(descriptor);
else
{
(void)close(descriptor);
}
descriptor = -1;
acceptOK = NO;
connectOK = NO;