cleanup getting descriptors/handles for ports.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@31288 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2010-09-10 08:56:55 +00:00
parent 8f19d8df47
commit 8ee8fb58b3
6 changed files with 49 additions and 42 deletions

View file

@ -1,3 +1,14 @@
2010-09-11 Richard Frith-Macdonald <rfm@gnu.org>
* NSSocketPort.m:
* unix/GSRunLoopCtxt.m:
* NSPort.m:
* NSMessagePort.m:
* win32/GSRunLoopCtxt.m:
Remove redundant check for responding to getFds:count: since it's
always true. Fix usage of method to correspond to prototype
(NSInteger arguments rather than int arguments).
2010-09-09 Eric Wasylishen <ewasylishen@gmail.com>
* Source/NSProtocolChecker.m: Replace a -[Protocol name] with
@ -10,8 +21,8 @@
2010-09-10 Riccardo Mottola
* Source/unix/GSRunLoopCtxt.m: only access array if port responds to selector, or it is not initialized
* Source/unix/GSRunLoopCtxt.m: only access array if port responds
to selector, or it is not initialized
* Source/NSDate.m,
* Source/NSScanner.m: use init return value

View file

@ -1405,7 +1405,7 @@ typedef struct {
* This is a callback method used by the NSRunLoop class to determine which
* descriptors to watch for the port.
*/
- (void) getFds: (int*)fds count: (int*)count
- (void) getFds: (NSInteger*)fds count: (NSInteger*)count
{
NSMapEnumerator me;
void *sock;

View file

@ -252,3 +252,13 @@ static Class NSPort_concrete_class;
@end
/*
* This is a callback method used by the NSRunLoop class to determine which
* descriptors to watch for the port. Subclasses override it.
*/
@implementation NSPort (GNUstep)
- (void) getFds: (NSInteger*)fds count: (NSInteger*)count
{
*count = 0;
}
@end

View file

@ -1828,7 +1828,7 @@ static Class tcpPortClass;
* descriptors to watch for the port.
*/
#if defined(__MINGW__)
- (void) getFds: (int*)fds count: (int*)count
- (void) getFds: (NSInteger*)fds count: (NSInteger*)count
{
NSMapEnumerator me;
void *event;
@ -1872,7 +1872,7 @@ static Class tcpPortClass;
M_UNLOCK(myLock);
}
#else
- (void) getFds: (int*)fds count: (int*)count
- (void) getFds: (NSInteger*)fds count: (NSInteger*)count
{
NSMapEnumerator me;
void *sock;

View file

@ -31,6 +31,8 @@
#include <unistd.h>
#endif
#define FDCOUNT 128
#if GS_WITH_GC == 0
static SEL wRelSel;
static SEL wRetSel;
@ -380,24 +382,18 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt)
case ET_RPORT:
{
id port = info->receiver;
NSInteger port_fd_count = FDCOUNT;
NSInteger port_fd_array[FDCOUNT];
if ([port respondsToSelector: @selector(getFds:count:)])
[port getFds: port_fd_array count: &port_fd_count];
NSDebugMLLog(@"NSRunLoop",
@"listening to %d port handles\n", port_fd_count);
while (port_fd_count--)
{
int port_fd_count = 128; // FIXME
int port_fd_array[port_fd_count];
[port getFds: port_fd_array
count: &port_fd_count];
NSDebugMLLog(@"NSRunLoop",
@"listening to %d port handles\n", port_fd_count);
while (port_fd_count--)
{
fd = port_fd_array[port_fd_count];
setPollfd(fd, POLLIN, self);
NSMapInsert(_rfdMap,
(void*)(intptr_t)port_fd_array[port_fd_count],
info);
}
fd = port_fd_array[port_fd_count];
setPollfd(fd, POLLIN, self);
NSMapInsert(_rfdMap,
(void*)(intptr_t)port_fd_array[port_fd_count], info);
}
}
break;
@ -800,15 +796,10 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt)
case ET_RPORT:
{
id port = info->receiver;
int port_fd_count = 128; // xxx #define this constant
int port_fd_array[port_fd_count];
NSInteger port_fd_count = FDCOUNT;
NSInteger port_fd_array[FDCOUNT];
if ([port respondsToSelector:
@selector(getFds:count:)])
{
[port getFds: port_fd_array
count: &port_fd_count];
}
[port getFds: port_fd_array count: &port_fd_count];
NSDebugMLLog(@"NSRunLoop", @"listening to %d port sockets",
port_fd_count);
while (port_fd_count--)

View file

@ -18,6 +18,8 @@
#import "../GSRunLoopWatcher.h"
#import "../GSPrivate.h"
#define FDCOUNT 128
#if GS_WITH_GC == 0
static SEL wRelSel;
static SEL wRetSel;
@ -346,24 +348,17 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks =
case ET_RPORT:
{
id port = info->receiver;
int port_handle_count = 128; // #define this constant
int port_handle_array[port_handle_count];
if ([port respondsToSelector: @selector(getFds:count:)])
{
[port getFds: port_handle_array
count: &port_handle_count];
}
else
{
NSLog(@"pollUntil - Impossible get win32 Handles");
abort();
}
NSInteger port_handle_count = FDCOUNT;
NSInteger port_handle_array[FDCOUNT];
[port getFds: port_handle_array count: &port_handle_count];
NSDebugMLLog(@"NSRunLoop", @"listening to %d port handles",
port_handle_count);
while (port_handle_count--)
{
NSMapInsert(handleMap,
(void*)(size_t) port_handle_array[port_handle_count], info);
(void*)(size_t) port_handle_array[port_handle_count],
info);
num_handles++;
}
}