#289 Incorrect return code from SecureStreamSocketImpl::sendBytes

closed
nobody
Net (141)
5
2012-09-14
2009-09-17
Lior Okman
No

Incorrect return code from SecureStreamSocketImpl::sendBytes if the underlying socket is non-blocking and the OpenSSL SSL_write() method returns SSL_ERROR_WANT_WRITE.

In this case, the current code will incorrectly retransmit part of the payload.

See the attached patch that fixes this behaviour.

Discussion

  • Lior Okman
    Lior Okman
    2009-09-17

    Patch to return a correct error code from sendBytes

     
  • fixed in 1.3.6

     
  • The fix is a bit different than your patch:

    int SecureStreamSocketImpl::sendBytes(const void buffer, int length, int flags)
    {
    const char
    p = reinterpret_cast<const char*="">(buffer);
    int remaining = length;
    int sent = 0;
    while (remaining > 0 && getBlocking())
    {
    int n = _impl.sendBytes(p, remaining, flags);
    if (n < 0) return n;
    p += n;
    remaining -= n;
    sent += n;
    }
    return sent;
    }