@@ -96,11 +96,11 @@ } } if (!found) { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; - struct pollfd p = { fd, events, 0 }; + struct pollfd p = { fd, events | POLLERR, 0 }; [fds addItem: &p]; [fdToStream setObject: stream forKey: [OFNumber numberWithInt: fd]]; [pool release]; } @@ -117,11 +117,11 @@ if (fds_c[i].fd == fd) { OFAutoreleasePool *pool; fds_c[i].events &= ~events; - if (fds_c[i].events != 0) + if ((fds_c[i].events & ~POLLERR) != 0) return; pool = [[OFAutoreleasePool alloc] init]; [fds removeItemAtIndex: i]; @@ -141,26 +141,31 @@ if (fd >= FD_SETSIZE) @throw [OFOutOfRangeException newWithClass: isa]; FD_SET(fd, fdset); + FD_SET(fd, &exceptfds); if (fd >= nfds) nfds = fd + 1; [pool release]; } - (void)_removeStream: (OFStream*)stream withFDSet: (fd_set*)fdset + otherFDSet: (fd_set*)other_fdset { int fd = [stream fileDescriptor]; if (fd >= FD_SETSIZE) @throw [OFOutOfRangeException newWithClass: isa]; FD_CLR(fd, fdset); + + if (!FD_ISSET(fd, other_fdset)) + FD_CLR(fd, &exceptfds); } #endif - (void)addStreamToObserveForReading: (OFStream*)stream { @@ -195,11 +200,12 @@ #ifdef OF_HAVE_POLL [self _removeStream: stream withEvents: POLLIN]; #else [self _removeStream: stream - withFDSet: &readfds]; + withFDSet: &readfds + otherFDSet: &writefds]; #endif } - (void)removeStreamToObserveForWriting: (OFStream*)stream { @@ -208,11 +214,12 @@ #ifdef OF_HAVE_POLL [self _removeStream: stream withEvents: POLLOUT]; #else [self _removeStream: stream - withFDSet: &writefds]; + withFDSet: &writefds + otherFDSet: &readfds]; #endif } - (void)observe { @@ -273,13 +280,19 @@ } fds_c[i].revents = 0; } #else +# ifdef FD_COPY + FD_COPY(readfds, readfds_); + FD_COPY(writefds, writefds_); + FD_COPY(exceptfds, exceptfds_); +# else readfds_ = readfds; writefds_ = writefds; - FD_ZERO(&exceptfds_); + exceptfds_ = exceptfds; +# endif if (select(nfds, &readfds_, &writefds_, &exceptfds_, (timeout != -1 ? &tv : NULL)) < 1) return NO; @@ -313,6 +326,10 @@ } - (void)streamDidBecomeReadyForWriting: (OFStream*)stream { } + +- (void)streamDidReceiveException: (OFStream*)stream +{ +} @end