@@ -15,10 +15,11 @@ */ #include "config.h" #include +#include #import "OFRunLoop.h" #import "OFRunLoop+Private.h" #import "OFDictionary.h" #ifdef OF_HAVE_SOCKETS @@ -31,10 +32,12 @@ #endif #import "OFSortedList.h" #import "OFTimer.h" #import "OFTimer+Private.h" #import "OFDate.h" + +#import "OFObserveFailedException.h" static OFRunLoop *mainRunLoop = nil; #ifdef OF_HAVE_SOCKETS @interface OFRunLoop_QueueItem: OFObject @@ -309,11 +312,11 @@ if (_block != NULL) return _block(object, _buffer, length, address, exception); else { # endif bool (*func)(id, SEL, OFUDPSocket *, void *, size_t, - of_udp_socket_address_t address, OFException *) = + of_udp_socket_address_t, OFException *) = (bool (*)(id, SEL, OFUDPSocket *, void *, size_t, of_udp_socket_address_t, OFException *)) [_target methodForSelector: _selector]; return func(_target, _selector, object, _buffer, length, @@ -425,17 +428,17 @@ queueItem->_target = [target retain]; queueItem->_selector = selector; }) } -+ (void)of_addAsyncReceiveForUDPSocket: (OFUDPSocket *)socket ++ (void)of_addAsyncReceiveForUDPSocket: (OFUDPSocket *)sock buffer: (void *)buffer length: (size_t)length target: (id)target selector: (SEL)selector { - ADD_READ(OFRunLoop_UDPReceiveQueueItem, socket, { + ADD_READ(OFRunLoop_UDPReceiveQueueItem, sock, { queueItem->_buffer = buffer; queueItem->_length = length; queueItem->_target = [target retain]; queueItem->_selector = selector; }) @@ -482,17 +485,17 @@ ADD_READ(OFRunLoop_AcceptQueueItem, stream, { queueItem->_block = [block copy]; }) } -+ (void)of_addAsyncReceiveForUDPSocket: (OFUDPSocket *)socket ++ (void)of_addAsyncReceiveForUDPSocket: (OFUDPSocket *)sock buffer: (void *)buffer length: (size_t)length block: (of_udp_socket_async_receive_block_t) block { - ADD_READ(OFRunLoop_UDPReceiveQueueItem, socket, { + ADD_READ(OFRunLoop_UDPReceiveQueueItem, sock, { queueItem->_buffer = buffer; queueItem->_length = length; queueItem->_block = [block copy]; }) } @@ -717,12 +720,17 @@ if (timeout < 0) timeout = 0; #if defined(OF_HAVE_SOCKETS) - [_kernelEventObserver - observeForTimeInterval: timeout]; + @try { + [_kernelEventObserver + observeForTimeInterval: timeout]; + } @catch (OFObserveFailedException *e) { + if ([e errNo] != EINTR) + @throw e; + } #elif defined(OF_HAVE_THREADS) [_condition lock]; [_condition waitForTimeInterval: timeout]; [_condition unlock]; #else @@ -733,11 +741,16 @@ * No more timers and no deadline: Just watch for I/O * until we get an event. If a timer is added by * another thread, it cancels the observe. */ #if defined(OF_HAVE_SOCKETS) - [_kernelEventObserver observe]; + @try { + [_kernelEventObserver observe]; + } @catch (OFObserveFailedException *e) { + if ([e errNo] != EINTR) + @throw e; + } #elif defined(OF_HAVE_THREADS) [_condition lock]; [_condition wait]; [_condition unlock]; #else