Commit c026dacf authored by plensing's avatar plensing Committed by GitHub
Browse files

Merge pull request #45 from golpa/master

Fixes EINTR bug within select
parents 24aeaf02 6841eae2
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -482,7 +482,7 @@ KineticStatus BlockingKineticConnection::RunOperation(
        tv.tv_usec = 0;

        int number_ready_fds = select(nfds, &read_fds, &write_fds, NULL, &tv);
        if (number_ready_fds < 0) {
        if (number_ready_fds < 0 && errno != EINTR) {
            // select() returned an error
            nonblocking_connection_->RemoveHandler(handler_key);
            return KineticStatus(StatusCode::CLIENT_IO_ERROR, strerror(errno));
@@ -490,7 +490,7 @@ KineticStatus BlockingKineticConnection::RunOperation(
            // select() returned before any sockets were ready meaning the connection timed out
            nonblocking_connection_->RemoveHandler(handler_key);
            return KineticStatus(StatusCode::CLIENT_IO_ERROR, "Network timeout");
        }
        } else {

            // At least one FD was ready meaning that the connection is ready
            // to make some progress
@@ -499,6 +499,7 @@ KineticStatus BlockingKineticConnection::RunOperation(
                return KineticStatus(StatusCode::CLIENT_IO_ERROR, "Connection failed");
            }
        }
    }

    // done was set, meaning handler was invoked and therefore removed internally