[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Flushing ssh_channel_write() ?
[Thread Prev] | [Thread Next]
- Subject: Re: Flushing ssh_channel_write() ?
- From: Jan Willamowius <jan@xxxxxxxxxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Mon, 21 Mar 2011 14:02:43 +0100
- To: libssh@xxxxxxxxxx
Hi, I would like to propose to add a new function to the API, so an application can ensure its data gets sent: int ssh_blocking_flush(ssh_session session) Please see the attached patch. It would be great if this could be included in the upcoming 0.5 release. I know its late in the cycle, but since it only adds a function, it can't break any existing code. Regards, Jan Jan Willamowius wrote: > Hi, > > while implementing my ssh server (with a 0.5 snapshot), I noticed that > data sent to the client with ssh_channel_write() doesn't seem to be sent > out immediately. Sometimes it only appears in the client when the client > presses another key. > > Is there a way to flush the data written with ssh_ channel_write() to > make sure it gets sent ? > > samplesshd doesn't have this issue, but my server doesn't enter > ssh_channel_read immediately after ssh_channel_write(). It only > does so when the client socket has new data to be read. > > Thanks, > Jan > > -- > Jan Willamowius, jan@xxxxxxxxxxxxxx, http://www.gnugk.org/ -- Jan Willamowius, jan@xxxxxxxxxxxxxx, http://www.gnugk.org/
--- include/libssh/libssh.h 2011-03-21 13:45:16.000000000 +0100
+++ ../orig/include/libssh/libssh.h 2011-03-09 18:33:49.000000000 +0100
@@ -386,7 +386,6 @@
LIBSSH_API int ssh_get_status(ssh_session session);
LIBSSH_API int ssh_init(void);
LIBSSH_API int ssh_is_blocking(ssh_session session);
-LIBSSH_API int ssh_blocking_flush(ssh_session session);
LIBSSH_API int ssh_is_connected(ssh_session session);
LIBSSH_API int ssh_is_server_known(ssh_session session);
LIBSSH_API void ssh_log(ssh_session session, int prioriry, const char *format, ...) PRINTF_ATTRIBUTE(3, 4);
--- src/socket.c 2011-03-21 13:55:20.000000000 +0100
+++ ../v0-5/src/socket.c 2011-03-09 18:33:49.000000000 +0100
@@ -558,53 +558,11 @@
ssh_set_error_oom(s->session);
return SSH_ERROR;
}
- ssh_socket_nonblocking_flush(s);
+ ssh_socket_nonblocking_flush(s);
}
leave_function();
return SSH_OK;
}
-
-/**
- * \brief possibly blocking flush of the output buffer
- *
- */
-int ssh_blocking_flush(ssh_session session) {
- ssh_socket s = session->socket;
- uint32_t len;
- int w;
-
- enter_function();
-
- if (!ssh_socket_is_open(s)) {
- session->alive = 0;
- /* FIXME use ssh_socket_get_errno */
- ssh_set_error(session, SSH_FATAL,
- "Writing packet: error on socket (or connection closed): %s",
- strerror(s->last_errno));
-
- leave_function();
- return SSH_ERROR;
- }
-
- len = buffer_get_rest_len(s->out_buffer);
- w = ssh_socket_unbuffered_write(s, buffer_get_rest(s->out_buffer), len);
- if (w < 0) {
- session->alive = 0;
- ssh_socket_close(s);
- /* FIXME use ssh_socket_get_errno() */
- /* FIXME use callback for errors */
- ssh_set_error(session, SSH_FATAL,
- "Writing packet: error on socket (or connection closed): %s",
- strerror(s->last_errno));
- leave_function();
- return SSH_ERROR;
- }
- buffer_pass_bytes(s->out_buffer, w);
-
- /* all data written */
- leave_function();
- return SSH_OK;
-}
/** \internal
| Re: Flushing ssh_channel_write() ? | Aris Adamantiadis <aris@xxxxxxxxxxxx> |