Roman Puls created PROTON-1165:
----------------------------------

             Summary: qpid proton cpp binding posix/io.cpp tests wrong error 
condition
                 Key: PROTON-1165
                 URL: https://issues.apache.org/jira/browse/PROTON-1165
             Project: Qpid Proton
          Issue Type: Bug
          Components: cpp-binding
    Affects Versions: 0.12.0
         Environment: linux/posix
            Reporter: Roman Puls
            Assignee: Cliff Jansen


posix/io.cpp:

size_t socket_engine::io_write(const char *buf, size_t size) {
    ssize_t n = ::write(socket_, buf, size);
    if (n == EAGAIN || n == EWOULDBLOCK) return 0;
    if (n < 0) check(n, "write: ");
    return n;
}

instead of testing n against EAGAIN/EWOULDBLOCK, n needs to be tested against 
-1 and then errno needs to be compared to EAGAIN/EWOULDBLOCK

proposed fix:

size_t socket_engine::io_write(const char *buf, size_t size) {
    ssize_t n = ::write(socket_, buf, size);

    if (n < 0) {
        if (errno == EAGAIN || errno == EWOULDBLOCK) {
            return 0;
        }
        check(n, "write: ");
    }
    return n;
}




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to