mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-11 18:50:28 +09:00
[channels] Added ssh_channel_window_size() and avoided reentrancy in channel_write_common()
(cherry picked from commit 7ba0938846)
This commit is contained in:
@@ -357,6 +357,7 @@ LIBSSH_API int ssh_channel_select(ssh_channel *readchans, ssh_channel *writechan
|
|||||||
timeval * timeout);
|
timeval * timeout);
|
||||||
LIBSSH_API void ssh_channel_set_blocking(ssh_channel channel, int blocking);
|
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 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,
|
LIBSSH_API int ssh_try_publickey_from_file(ssh_session session, const char *keyfile,
|
||||||
ssh_string *publickey, int *type);
|
ssh_string *publickey, int *type);
|
||||||
|
|||||||
@@ -1155,15 +1155,12 @@ int channel_write_common(ssh_channel channel, const void *data,
|
|||||||
"Remote window is %d bytes. going to write %d bytes",
|
"Remote window is %d bytes. going to write %d bytes",
|
||||||
channel->remote_window,
|
channel->remote_window,
|
||||||
len);
|
len);
|
||||||
ssh_log(session, SSH_LOG_PROTOCOL,
|
|
||||||
"Waiting for a growing window message...");
|
|
||||||
/* What happens when the channel window is zero? */
|
/* What happens when the channel window is zero? */
|
||||||
while(channel->remote_window == 0) {
|
if(channel->remote_window == 0) {
|
||||||
/* parse every incoming packet */
|
/* nothing can be written */
|
||||||
if (ssh_handle_packets(session,-1) == SSH_ERROR) {
|
ssh_log(session, SSH_LOG_PROTOCOL,
|
||||||
leave_function();
|
"Wait for a growing window message...");
|
||||||
return SSH_ERROR;
|
return 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
effectivelen = len > channel->remote_window ? channel->remote_window : len;
|
effectivelen = len > channel->remote_window ? channel->remote_window : len;
|
||||||
} else {
|
} else {
|
||||||
@@ -1212,6 +1209,10 @@ error:
|
|||||||
return SSH_ERROR;
|
return SSH_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t ssh_channel_window_size(ssh_channel channel) {
|
||||||
|
return channel->remote_window;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Blocking write on a channel.
|
* @brief Blocking write on a channel.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user