session/transport: Correctly handle when _libssh2_send() returns -EAGAIN
This commit is contained in:
parent
e8c44e789f
commit
80f7508d55
@ -239,11 +239,12 @@ banner_send(LIBSSH2_SESSION * session)
|
|||||||
banner, session->banner_TxRx_total_send);
|
banner, session->banner_TxRx_total_send);
|
||||||
|
|
||||||
if (ret != (banner_len - session->banner_TxRx_total_send)) {
|
if (ret != (banner_len - session->banner_TxRx_total_send)) {
|
||||||
if ((ret > 0) || ((ret == -1) && (ret == -EAGAIN))) {
|
if (ret >= 0 || ret == -EAGAIN) {
|
||||||
/* the whole packet could not be sent, save the what was */
|
/* the whole packet could not be sent, save the what was */
|
||||||
session->socket_block_directions =
|
session->socket_block_directions =
|
||||||
LIBSSH2_SESSION_BLOCK_OUTBOUND;
|
LIBSSH2_SESSION_BLOCK_OUTBOUND;
|
||||||
session->banner_TxRx_total_send += ret;
|
if (ret > 0)
|
||||||
|
session->banner_TxRx_total_send += ret;
|
||||||
return LIBSSH2_ERROR_EAGAIN;
|
return LIBSSH2_ERROR_EAGAIN;
|
||||||
}
|
}
|
||||||
session->banner_TxRx_state = libssh2_NB_state_idle;
|
session->banner_TxRx_state = libssh2_NB_state_idle;
|
||||||
|
@ -601,12 +601,10 @@ send_existing(LIBSSH2_SESSION *session, const unsigned char *data,
|
|||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
_libssh2_debug(session, LIBSSH2_TRACE_SOCKET,
|
_libssh2_debug(session, LIBSSH2_TRACE_SOCKET,
|
||||||
"Error sending %d bytes: %d", length, -rc);
|
"Error sending %d bytes: %d", length, -rc);
|
||||||
else
|
else {
|
||||||
_libssh2_debug(session, LIBSSH2_TRACE_SOCKET,
|
_libssh2_debug(session, LIBSSH2_TRACE_SOCKET,
|
||||||
"Sent %d/%d bytes at %p+%d", rc, length, p->outbuf,
|
"Sent %d/%d bytes at %p+%d", rc, length, p->outbuf,
|
||||||
p->osent);
|
p->osent);
|
||||||
|
|
||||||
if(rc > 0) {
|
|
||||||
debugdump(session, "libssh2_transport_write send()",
|
debugdump(session, "libssh2_transport_write send()",
|
||||||
&p->outbuf[p->osent], rc);
|
&p->outbuf[p->osent], rc);
|
||||||
}
|
}
|
||||||
@ -813,20 +811,19 @@ int _libssh2_transport_send(LIBSSH2_SESSION *session,
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
_libssh2_debug(session, LIBSSH2_TRACE_SOCKET,
|
_libssh2_debug(session, LIBSSH2_TRACE_SOCKET,
|
||||||
"Error sending %d bytes: %d", total_length, -ret);
|
"Error sending %d bytes: %d", total_length, -ret);
|
||||||
else
|
else {
|
||||||
_libssh2_debug(session, LIBSSH2_TRACE_SOCKET, "Sent %d/%d bytes at %p",
|
_libssh2_debug(session, LIBSSH2_TRACE_SOCKET, "Sent %d/%d bytes at %p",
|
||||||
ret, total_length, p->outbuf);
|
ret, total_length, p->outbuf);
|
||||||
|
|
||||||
if (ret != -1) {
|
|
||||||
debugdump(session, "libssh2_transport_write send()", p->outbuf, ret);
|
debugdump(session, "libssh2_transport_write send()", p->outbuf, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret != total_length) {
|
if (ret != total_length) {
|
||||||
if ((ret > 0) || ((ret == -1) && (ret == -EAGAIN))) {
|
if (ret >= 0 || ret == -EAGAIN) {
|
||||||
/* the whole packet could not be sent, save the rest */
|
/* the whole packet could not be sent, save the rest */
|
||||||
session->socket_block_directions |= LIBSSH2_SESSION_BLOCK_OUTBOUND;
|
session->socket_block_directions |= LIBSSH2_SESSION_BLOCK_OUTBOUND;
|
||||||
p->odata = orgdata;
|
p->odata = orgdata;
|
||||||
p->olen = orgdata_len;
|
p->olen = orgdata_len;
|
||||||
p->osent = (ret == -1) ? 0 : ret;
|
p->osent = ret <= 0 ? 0 : ret;
|
||||||
p->ototal_num = total_length;
|
p->ototal_num = total_length;
|
||||||
return LIBSSH2_ERROR_EAGAIN;
|
return LIBSSH2_ERROR_EAGAIN;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user