From 52e900d07c2d60611cf6e0e61384a0aba7575a70 Mon Sep 17 00:00:00 2001 From: wlux Date: Thu, 7 Jun 2012 08:11:59 +0000 Subject: [PATCH] Fix previous change to compile again when using select() instead of poll(). git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@35182 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 5 +++ Source/unix/GSRunLoopCtxt.m | 62 ++++++++++++++++++------------------- 2 files changed, 35 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index 078cd29a7..b2c5e6d74 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2012-06-07 Wolfgang Lux + + * Source/unix/GSRunLoopCtxt.m (-pollUntil:within:): Fix previous + change to compile again when using select() instead of poll(). + 2012-06-06 Richard Frith-Macdonald * Source/NSSocketPort.m: diff --git a/Source/unix/GSRunLoopCtxt.m b/Source/unix/GSRunLoopCtxt.m index a254c2ebe..ac2429313 100644 --- a/Source/unix/GSRunLoopCtxt.m +++ b/Source/unix/GSRunLoopCtxt.m @@ -398,8 +398,7 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) { fd = port_fd_array[port_fd_count]; setPollfd(fd, POLLIN, self); - NSMapInsert(_rfdMap, - (void*)(intptr_t)port_fd_array[port_fd_count], info); + NSMapInsert(_rfdMap, (void*)(intptr_t)fd, info); } if (port_fd_array != port_fd_buffer) free(port_fd_array); } @@ -507,13 +506,13 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) } /* - * Look at all the file descriptors select() says are ready for action; + * Look at all the file descriptors poll() says are ready for action; * notify the corresponding object for each of the ready fd's. * NB. It is possible for a watcher to be missing from the map - if * the event handler of a previous watcher has 'run' the loop again * before returning. * NB. Each time this loop is entered, the starting position (fairStart) - * is incremented - this is to ensure a fair distribion over all + * is incremented - this is to ensure a fair distribution over all * inputs where multiple inputs are in use. Note - fairStart can be * modified while we are in the loop (by recursive calls). */ @@ -806,7 +805,7 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) NSInteger port_fd_size = FDCOUNT; NSInteger port_fd_count = FDCOUNT; NSInteger port_fd_buffer[FDCOUNT]; - NSInteger port_fd_array = port_fd_count; + NSInteger *port_fd_array = port_fd_buffer; [port getFds: port_fd_array count: &port_fd_count]; while (port_fd_count > port_fd_size) @@ -822,11 +821,10 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) while (port_fd_count--) { fd = port_fd_array[port_fd_count]; - FD_SET (port_fd_array[port_fd_count], &read_fds); if (fd > fdEnd) fdEnd = fd; - NSMapInsert(_rfdMap, - (void*)(intptr_t)port_fd_array[port_fd_count], info); + FD_SET (fd, &read_fds); + NSMapInsert(_rfdMap, (void*)(intptr_t)fd, info); } if (port_fd_array != port_fd_buffer) free(port_fd_array); } @@ -892,28 +890,28 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) GSRunLoopWatcher *watcher; watcher = (GSRunLoopWatcher*)GSIArrayItemAtIndex(_trigger, count).obj; - if (watcher->_invalidated == NO) - { - i = [contexts count]; - while (i-- > 0) - { - GSRunLoopCtxt *c = [contexts objectAtIndex: i]; + if (watcher->_invalidated == NO) + { + i = [contexts count]; + while (i-- > 0) + { + GSRunLoopCtxt *c = [contexts objectAtIndex: i]; - if (c != self) - { - [c endEvent: (void*)watcher for: watcher]; - } - } - /* - * The watcher is still valid - so call its - * receivers event handling method. - */ - [watcher->receiver receivedEvent: watcher->data - type: watcher->type - extra: watcher->data - forMode: mode]; - } - GSPrivateNotifyASAP(mode); + if (c != self) + { + [c endEvent: (void*)watcher for: watcher]; + } + } + /* + * The watcher is still valid - so call its + * receivers event handling method. + */ + [watcher->receiver receivedEvent: watcher->data + type: watcher->type + extra: watcher->data + forMode: mode]; + } + GSPrivateNotifyASAP(mode); } /* @@ -924,12 +922,12 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) completed = YES; return NO; } - + /* * Look at all the file descriptors select() says are ready for action; * notify the corresponding object for each of the ready fd's. - * NB. Each time this roop is entered, the starting position (fairStart) - * is incremented - this is to ensure a fair distribtion over all + * NB. Each time this loop is entered, the starting position (fairStart) + * is incremented - this is to ensure a fair distribution over all * inputs where multiple inputs are in use. Note - fairStart can be * modified while we are in the loop (by recursive calls). */