Index: src/OFHTTPServer.m ================================================================== --- src/OFHTTPServer.m +++ src/OFHTTPServer.m @@ -230,11 +230,11 @@ if (!_chunked) { @try { [_socket writeBuffer: buffer length: length]; } @catch (OFWriteFailedException *e) { - if (e.errNo == EWOULDBLOCK) + if (e.errNo == EWOULDBLOCK || e.errNo == EAGAIN) return e.bytesWritten; @throw e; } Index: src/OFLHAArchive.m ================================================================== --- src/OFLHAArchive.m +++ src/OFLHAArchive.m @@ -487,11 +487,11 @@ OFEnsure(e.bytesWritten <= length); _bytesWritten += (uint32_t)e.bytesWritten; _CRC16 = OFCRC16(_CRC16, buffer, e.bytesWritten); - if (e.errNo == EWOULDBLOCK) + if (e.errNo == EWOULDBLOCK || e.errNo == EAGAIN) return e.bytesWritten; @throw e; } Index: src/OFRunLoop.m ================================================================== --- src/OFRunLoop.m +++ src/OFRunLoop.m @@ -573,11 +573,11 @@ length = dataLength - _writtenLength; [object writeBuffer: dataItems + _writtenLength length: length]; } @catch (OFWriteFailedException *e) { length = e.bytesWritten; - if (e.errNo != EWOULDBLOCK) + if (e.errNo != EWOULDBLOCK && e.errNo != EAGAIN) exception = e; } @catch (id e) { length = 0; exception = e; } @@ -650,11 +650,11 @@ length = cStringLength - _writtenLength; [object writeBuffer: cString + _writtenLength length: length]; } @catch (OFWriteFailedException *e) { length = e.bytesWritten; - if (e.errNo != EWOULDBLOCK) + if (e.errNo != EWOULDBLOCK && e.errNo != EAGAIN) exception = e; } @catch (id e) { length = 0; exception = e; } Index: src/OFStream.h ================================================================== --- src/OFStream.h +++ src/OFStream.h @@ -829,12 +829,14 @@ /** * @brief Writes from a buffer into the stream. * * In non-blocking mode, if less than the specified length could be written, an * @ref OFWriteFailedException is thrown with @ref OFWriteFailedException#errNo - * being set to `EWOULDBLOCK` and @ref OFWriteFailedException#bytesWritten - * being set to the number of bytes that were written, if any. + * being set to `EWOULDBLOCK` or `EAGAIN` (you need to check for both, as they + * are not the same on some systems) and + * @ref OFWriteFailedException#bytesWritten being set to the number of bytes + * that were written, if any. * * @param buffer The buffer from which the data is written into the stream * @param length The length of the data that should be written */ - (void)writeBuffer: (const void *)buffer length: (size_t)length; Index: src/OFTarArchive.m ================================================================== --- src/OFTarArchive.m +++ src/OFTarArchive.m @@ -442,11 +442,11 @@ } @catch (OFWriteFailedException *e) { OFEnsure(e.bytesWritten <= length); _toWrite -= e.bytesWritten; - if (e.errNo == EWOULDBLOCK) + if (e.errNo == EWOULDBLOCK || e.errNo == EAGAIN) return e.bytesWritten; @throw e; } Index: src/OFZIPArchive.m ================================================================== --- src/OFZIPArchive.m +++ src/OFZIPArchive.m @@ -897,11 +897,11 @@ OFEnsure(e.bytesWritten <= length); _bytesWritten += (int64_t)e.bytesWritten; _CRC32 = OFCRC32(_CRC32, buffer, e.bytesWritten); - if (e.errNo == EWOULDBLOCK) + if (e.errNo == EWOULDBLOCK || e.errNo == EAGAIN) return e.bytesWritten; @throw e; } Index: src/tls/OFGnuTLSTLSStream.m ================================================================== --- src/tls/OFGnuTLSTLSStream.m +++ src/tls/OFGnuTLSTLSStream.m @@ -48,11 +48,11 @@ gnutls_transport_set_errno(stream->_session, e.errNo); return -1; } if (length == 0 && !stream.underlyingStream.atEndOfStream) { - gnutls_transport_set_errno(stream->_session, EWOULDBLOCK); + gnutls_transport_set_errno(stream->_session, EAGAIN); return -1; } return length; } @@ -65,11 +65,11 @@ @try { [stream.underlyingStream writeBuffer: buffer length: length]; } @catch (OFWriteFailedException *e) { gnutls_transport_set_errno(stream->_session, e.errNo); - if (e.errNo == EWOULDBLOCK) + if (e.errNo == EWOULDBLOCK || e.errNo == EAGAIN) return e.bytesWritten; return -1; } @@ -146,11 +146,11 @@ /* * The underlying stream might have had data ready, but not * enough for GnuTLS to return decrypted data. This means the * caller might have observed the TLS stream for reading, got a * ready signal and read - and expects the read to succeed, not - * to fail with EWOULDBLOCK, as it was signaled ready. + * to fail with EWOULDBLOCK/EAGAIN, as it was signaled ready. * Therefore, return 0, as we could read 0 decrypted bytes, but * cleared the ready signal of the underlying stream. */ if (ret == GNUTLS_E_INTERRUPTED || ret == GNUTLS_E_AGAIN) return 0; @@ -170,20 +170,18 @@ if (!_handshakeDone) @throw [OFNotOpenException exceptionWithObject: self]; if ((ret = gnutls_record_send(_session, buffer, length)) < 0) { - /* FIXME: Translate error to errNo */ - int errNo = 0; - if (ret == GNUTLS_E_INTERRUPTED || ret == GNUTLS_E_AGAIN) - errNo = EWOULDBLOCK; + return 0; + /* FIXME: Translate error to errNo */ @throw [OFWriteFailedException exceptionWithObject: self requestedLength: length bytesWritten: ret - errNo: errNo]; + errNo: 0]; } return ret; } Index: src/tls/OFSecureTransportTLSStream.m ================================================================== --- src/tls/OFSecureTransportTLSStream.m +++ src/tls/OFSecureTransportTLSStream.m @@ -36,11 +36,11 @@ @try { length = [((OFTLSStream *)connection).underlyingStream readIntoBuffer: data length: *dataLength]; } @catch (OFReadFailedException *e) { - if (e.errNo == EWOULDBLOCK) { + if (e.errNo == EWOULDBLOCK || e.errNo == EAGAIN) { *dataLength = 0; return errSSLWouldBlock; } @throw e; @@ -60,11 +60,11 @@ writeBuffer: data length: *dataLength]; } @catch (OFWriteFailedException *e) { *dataLength = e.bytesWritten; - if (e.errNo == EWOULDBLOCK) + if (e.errNo == EWOULDBLOCK || e.errNo == EAGAIN) return errSSLWouldBlock; @throw e; }