aboutsummaryrefslogtreecommitdiff
path: root/src/channels.c
diff options
context:
space:
mode:
authormilo <milo@r0ot.me>2012-05-02 19:02:47 +0200
committermilo <milo@r0ot.me>2012-05-05 18:04:13 +0200
commit99f14ec89092d315fbe9909fd0c91a979231fc5e (patch)
tree797e787c26917ea5c81d3ed29304560b2de2a713 /src/channels.c
parent386b0d087dd3e1056de0a86e242a97b51e2080e3 (diff)
downloadlibssh-99f14ec89092d315fbe9909fd0c91a979231fc5e.tar.gz
libssh-99f14ec89092d315fbe9909fd0c91a979231fc5e.tar.xz
libssh-99f14ec89092d315fbe9909fd0c91a979231fc5e.zip
Manage channel data sequentially, send EOF at the end
Diffstat (limited to 'src/channels.c')
-rw-r--r--src/channels.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/channels.c b/src/channels.c
index bc4d9bb..be12d0b 100644
--- a/src/channels.c
+++ b/src/channels.c
@@ -487,10 +487,13 @@ SSH_PACKET_CALLBACK(channel_rcv_change_window) {
SSH_PACKET_CALLBACK(channel_rcv_data){
ssh_channel channel;
ssh_string str;
- ssh_buffer buf;
size_t len;
int is_stderr;
+#ifdef WITH_SERVER
+#else
+ ssh_buffer buf;
int rest;
+#endif
(void)user;
enter_function();
if(type==SSH2_MSG_CHANNEL_DATA)
@@ -555,6 +558,8 @@ SSH_PACKET_CALLBACK(channel_rcv_data){
ssh_string_free(str);
+#ifdef WITH_SERVER
+#else
if(ssh_callbacks_exists(channel->callbacks, channel_data_function)) {
if(is_stderr) {
buf = channel->stderr_buffer;
@@ -571,12 +576,13 @@ SSH_PACKET_CALLBACK(channel_rcv_data){
buffer_pass_bytes(buf, rest);
channel->local_window_buffer -= rest;
}
+ }
+#endif
if (channel->local_window + channel->local_window_buffer < WINDOWLIMIT) {
if (grow_window(session, channel, 0) < 0) {
leave_function();
return -1;
}
- }
}
leave_function();
@@ -603,10 +609,13 @@ SSH_PACKET_CALLBACK(channel_rcv_eof) {
/* channel->remote_window = 0; */
channel->remote_eof = 1;
- if(ssh_callbacks_exists(channel->callbacks, channel_eof_function)) {
- channel->callbacks->channel_eof_function(channel->session,
+ if(ssh_channel_is_eof(channel)) {
+ if(ssh_callbacks_exists(channel->callbacks, channel_eof_function)) {
+ channel->callbacks->channel_eof_function(channel->session,
channel,
channel->callbacks->userdata);
+ channel->remote_eof = 2; /* EOF callback has been called */
+ }
}
leave_function();
@@ -649,11 +658,13 @@ SSH_PACKET_CALLBACK(channel_rcv_close) {
* buffer because the eof is ignored until the buffer is empty.
*/
+ if(ssh_channel_is_eof(channel)) {
if(ssh_callbacks_exists(channel->callbacks, channel_close_function)) {
channel->callbacks->channel_close_function(channel->session,
channel,
channel->callbacks->userdata);
}
+ }
channel->flags &= SSH_CHANNEL_FLAG_CLOSED_REMOTE;
if(channel->flags & SSH_CHANNEL_FLAG_FREED_LOCAL)
ssh_channel_do_free(channel);