Index: src/OFStreamObserver.h ================================================================== --- src/OFStreamObserver.h +++ src/OFStreamObserver.h @@ -171,14 +171,14 @@ /** * \brief Observes all streams until an event happens on a stream or the * timeout is reached. * - * \param timeout The time to wait for an event, in milliseconds + * \param timeout The time to wait for an event, in seconds * \return A boolean whether events occurred during the timeinterval */ -- (BOOL)observeWithTimeout: (int)timeout; +- (BOOL)observeWithTimeout: (double)timeout; - (void)_addFileDescriptorForReading: (int)fd; - (void)_addFileDescriptorForWriting: (int)fd; - (void)_removeFileDescriptorForReading: (int)fd; - (void)_removeFileDescriptorForWriting: (int)fd; Index: src/OFStreamObserver.m ================================================================== --- src/OFStreamObserver.m +++ src/OFStreamObserver.m @@ -368,11 +368,11 @@ - (void)observe { [self observeWithTimeout: -1]; } -- (BOOL)observeWithTimeout: (int)timeout +- (BOOL)observeWithTimeout: (double)timeout { @throw [OFNotImplementedException exceptionWithClass: [self class] selector: _cmd]; } Index: src/OFStreamObserver_kqueue.m ================================================================== --- src/OFStreamObserver_kqueue.m +++ src/OFStreamObserver_kqueue.m @@ -96,17 +96,20 @@ EV_SET(&event, fd, EVFILT_WRITE, EV_DELETE, 0, 0, 0); [changeList addItem: &event]; } -- (BOOL)observeWithTimeout: (int)timeout +- (BOOL)observeWithTimeout: (double)timeout { void *pool = objc_autoreleasePoolPush(); - struct timespec timespec = { timeout, 0 }; + struct timespec timespec; struct kevent eventList[EVENTLIST_SIZE]; int i, events; + timespec.tv_sec = timeout; + timespec.tv_nsec = (timeout - timespec.tv_sec) * 1000000000; + [self _processQueue]; if ([self _processCache]) { objc_autoreleasePoolPop(pool); return YES; Index: src/OFStreamObserver_poll.m ================================================================== --- src/OFStreamObserver_poll.m +++ src/OFStreamObserver_poll.m @@ -118,11 +118,11 @@ { [self _removeFileDescriptor: fd withEvents: POLLOUT]; } -- (BOOL)observeWithTimeout: (int)timeout +- (BOOL)observeWithTimeout: (double)timeout { void *pool = objc_autoreleasePoolPush(); struct pollfd *FDsCArray; size_t i, nFDs; @@ -141,11 +141,12 @@ #ifdef OPEN_MAX if (nFDs > OPEN_MAX) @throw [OFOutOfRangeException exceptionWithClass: [self class]]; #endif - if (poll(FDsCArray, (nfds_t)nFDs, timeout) < 1) + if (poll(FDsCArray, (nfds_t)nFDs, + (timeout != -1 ? timeout * 1000 : -1)) < 1) return NO; for (i = 0; i < nFDs; i++) { pool = objc_autoreleasePoolPush(); Index: src/OFStreamObserver_select.m ================================================================== --- src/OFStreamObserver_select.m +++ src/OFStreamObserver_select.m @@ -67,11 +67,11 @@ if (!FD_ISSET(fd, &readFDs)) FD_CLR(fd, &exceptFDs); } -- (BOOL)observeWithTimeout: (int)timeout +- (BOOL)observeWithTimeout: (double)timeout { void *pool = objc_autoreleasePoolPush(); OFStream **objects; fd_set readFDs_; fd_set writeFDs_; @@ -96,12 +96,12 @@ readFDs_ = readFDs; writeFDs_ = writeFDs; exceptFDs_ = exceptFDs; #endif - time.tv_sec = timeout / 1000; - time.tv_usec = (timeout % 1000) * 1000; + time.tv_sec = timeout; + time.tv_usec = (timeout - time.tv_sec) * 1000; if (select((int)maxFD + 1, &readFDs_, &writeFDs_, &exceptFDs_, (timeout != -1 ? &time : NULL)) < 1) return NO;