From 9b79aba3b258febb4f75bc5f0df9f03d6a450b3f Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Wed, 31 May 2017 20:24:28 +0200 Subject: [PATCH] No need to convert to IOError if EWOULDBLOCK --- Sources/Sockets/IO.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/Sockets/IO.swift b/Sources/Sockets/IO.swift index 759384b92..832b82dbd 100644 --- a/Sources/Sockets/IO.swift +++ b/Sources/Sockets/IO.swift @@ -55,12 +55,12 @@ func wrapSyscall(_ successCondition: (Int) -> Bool, func wrapSyscallMayBlock(_ successCondition: (Int) -> Bool, function: @autoclosure () -> String, _ fn: () -> Int) throws -> Int? { do { - return try wrapSyscall(function: function, successCondition, fn) - } catch let error as IOError { - if error.errno == EWOULDBLOCK { + return try withErrno(hint: "", successCondition: successCondition, fn) + } catch let e as POSIXReasonedError { + if e.code == EWOULDBLOCK { return nil; } - throw error + throw ioError(errno: e.code, function: function()) } }