From 43e3a8e497935fd28f1df43933d5c97d02545e4f Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 17 Jul 2012 18:03:34 +0200 Subject: socket: Add a SSH_WRITE_PENDING socket status. --- src/session.c | 10 +++++++--- src/socket.c | 4 ++++ 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/session.c b/src/session.c index 1e81edc..174d461 100644 --- a/src/session.c +++ b/src/session.c @@ -527,9 +527,10 @@ int ssh_handle_packets_termination(ssh_session session, int timeout, * * @param session The ssh session to use. * - * @returns A bitmask including SSH_CLOSED, SSH_READ_PENDING or SSH_CLOSED_ERROR - * which respectively means the session is closed, has data to read on - * the connection socket and session was closed due to an error. + * @returns A bitmask including SSH_CLOSED, SSH_READ_PENDING, SSH_WRITE_PENDING + * or SSH_CLOSED_ERROR which respectively means the session is closed, + * has data to read on the connection socket and session was closed + * due to an error. */ int ssh_get_status(ssh_session session) { int socketstate; @@ -547,6 +548,9 @@ int ssh_get_status(ssh_session session) { if (socketstate & SSH_READ_PENDING) { r |= SSH_READ_PENDING; } + if (socketstate & SSH_WRITE_PENDING) { + r |= SSH_WRITE_PENDING; + } if (session->closed && (socketstate & SSH_CLOSED_ERROR)) { r |= SSH_CLOSED_ERROR; } diff --git a/src/socket.c b/src/socket.c index 5bde836..338bda0 100644 --- a/src/socket.c +++ b/src/socket.c @@ -694,6 +694,10 @@ int ssh_socket_get_status(ssh_socket s) { r |= SSH_READ_PENDING; } + if (s->write_wontblock) { + r |= SSH_WRITE_PENDING; + } + if (s->data_except) { r |= SSH_CLOSED_ERROR; } -- cgit