mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-11 18:50:28 +09:00
channels: Fix bug #52.
(cherry picked from commit a2c94abb92)
Conflicts:
src/channels.c
This commit is contained in:
@@ -1133,6 +1133,8 @@ int channel_write_common(ssh_channel channel, const void *data,
|
|||||||
uint32_t origlen = len;
|
uint32_t origlen = len;
|
||||||
size_t effectivelen;
|
size_t effectivelen;
|
||||||
size_t maxpacketlen;
|
size_t maxpacketlen;
|
||||||
|
int timeout;
|
||||||
|
int rc;
|
||||||
|
|
||||||
if(channel == NULL || data == NULL) {
|
if(channel == NULL || data == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
@@ -1150,7 +1152,10 @@ int channel_write_common(ssh_channel channel, const void *data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
enter_function();
|
enter_function();
|
||||||
|
if(ssh_is_blocking(session))
|
||||||
|
timeout = -2;
|
||||||
|
else
|
||||||
|
timeout = 0;
|
||||||
/*
|
/*
|
||||||
* Handle the max packet len from remote side, be nice
|
* Handle the max packet len from remote side, be nice
|
||||||
* 10 bytes for the headers
|
* 10 bytes for the headers
|
||||||
@@ -1174,7 +1179,7 @@ int channel_write_common(ssh_channel channel, const void *data,
|
|||||||
|
|
||||||
#ifdef WITH_SSH1
|
#ifdef WITH_SSH1
|
||||||
if (channel->version == 1) {
|
if (channel->version == 1) {
|
||||||
int rc = channel_write1(channel, data, len);
|
rc = channel_write1(channel, data, len);
|
||||||
leave_function();
|
leave_function();
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@@ -1191,7 +1196,10 @@ int channel_write_common(ssh_channel channel, const void *data,
|
|||||||
/* nothing can be written */
|
/* nothing can be written */
|
||||||
ssh_log(session, SSH_LOG_PROTOCOL,
|
ssh_log(session, SSH_LOG_PROTOCOL,
|
||||||
"Wait for a growing window message...");
|
"Wait for a growing window message...");
|
||||||
|
rc = ssh_handle_packets(session, timeout);
|
||||||
|
if (rc == SSH_ERROR || (channel->remote_window == 0 && timeout==0))
|
||||||
goto out;
|
goto out;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
effectivelen = len > channel->remote_window ? channel->remote_window : len;
|
effectivelen = len > channel->remote_window ? channel->remote_window : len;
|
||||||
} else {
|
} else {
|
||||||
@@ -1230,7 +1238,10 @@ int channel_write_common(ssh_channel channel, const void *data,
|
|||||||
len -= effectivelen;
|
len -= effectivelen;
|
||||||
data = ((uint8_t*)data + effectivelen);
|
data = ((uint8_t*)data + effectivelen);
|
||||||
}
|
}
|
||||||
|
/* it's a good idea to flush the socket now */
|
||||||
|
do {
|
||||||
|
rc = ssh_handle_packets(session, timeout);
|
||||||
|
} while(ssh_socket_buffered_write_bytes(session->socket) > 0 && timeout != 0);
|
||||||
out:
|
out:
|
||||||
leave_function();
|
leave_function();
|
||||||
return (int)(origlen - len);
|
return (int)(origlen - len);
|
||||||
|
|||||||
Reference in New Issue
Block a user