aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/libssh/libssh.h1
-rw-r--r--src/channels.c17
2 files changed, 10 insertions, 8 deletions
diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h
index 5137cbb3..101508ed 100644
--- a/include/libssh/libssh.h
+++ b/include/libssh/libssh.h
@@ -359,6 +359,7 @@ LIBSSH_API int ssh_channel_select(ssh_channel *readchans, ssh_channel *writechan
timeval * timeout);
LIBSSH_API void ssh_channel_set_blocking(ssh_channel channel, int blocking);
LIBSSH_API int ssh_channel_write(ssh_channel channel, const void *data, uint32_t len);
+LIBSSH_API uint32_t ssh_channel_window_size(ssh_channel channel);
LIBSSH_API int ssh_try_publickey_from_file(ssh_session session, const char *keyfile,
ssh_string *publickey, int *type);
diff --git a/src/channels.c b/src/channels.c
index 15e1e668..913b61b3 100644
--- a/src/channels.c
+++ b/src/channels.c
@@ -1173,15 +1173,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 {
@@ -1230,6 +1227,10 @@ error:
return SSH_ERROR;
}
+uint32_t ssh_channel_window_size(ssh_channel channel) {
+ return channel->remote_window;
+}
+
/**
* @brief Blocking write on a channel.
*