summaryrefslogtreecommitdiffstats
path: root/src/channels.c
diff options
context:
space:
mode:
authormilo <milo@r0ot.me>2011-04-20 02:06:43 +0200
committermilo <milo@r0ot.me>2011-05-02 17:35:34 +0200
commitbb784ec6be1b15c1895d4ec6fb31e35bc29dec81 (patch)
tree765442f8b58a17fef88beeaf46ac2098c5e522ce /src/channels.c
parent996c00c81c469ac0d8e8c027ad0650abdc6fc952 (diff)
downloadlibssh-bb784ec6be1b15c1895d4ec6fb31e35bc29dec81.tar.gz
libssh-bb784ec6be1b15c1895d4ec6fb31e35bc29dec81.tar.xz
libssh-bb784ec6be1b15c1895d4ec6fb31e35bc29dec81.zip
[channels] Added ssh_channel_window_size() and avoided reentrancy in channel_write_common()
(cherry picked from commit 7ba09388464f0437da2833b81e268744b20a68fe)
Diffstat (limited to 'src/channels.c')
-rw-r--r--src/channels.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/channels.c b/src/channels.c
index cd11ca77..6f39b9c6 100644
--- a/src/channels.c
+++ b/src/channels.c
@@ -1155,15 +1155,12 @@ int channel_write_common(ssh_channel channel, const void *data,
"Remote window is %d bytes. going to write %d bytes",
channel->remote_window,
len);
- ssh_log(session, SSH_LOG_PROTOCOL,
- "Waiting for a growing window message...");
/* What happens when the channel window is zero? */
- while(channel->remote_window == 0) {
- /* parse every incoming packet */
- if (ssh_handle_packets(session,-1) == SSH_ERROR) {
- leave_function();
- return SSH_ERROR;
- }
+ if(channel->remote_window == 0) {
+ /* nothing can be written */
+ ssh_log(session, SSH_LOG_PROTOCOL,
+ "Wait for a growing window message...");
+ return 0;
}
effectivelen = len > channel->remote_window ? channel->remote_window : len;
} else {
@@ -1212,6 +1209,10 @@ error:
return SSH_ERROR;
}
+uint32_t ssh_channel_window_size(ssh_channel channel) {
+ return channel->remote_window;
+}
+
/**
* @brief Blocking write on a channel.
*