summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/libssh/libssh.h1
-rw-r--r--src/session.c10
-rw-r--r--src/socket.c4
3 files changed, 12 insertions, 3 deletions
diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h
index 0167b4a..40a32be 100644
--- a/include/libssh/libssh.h
+++ b/include/libssh/libssh.h
@@ -211,6 +211,7 @@ enum ssh_publickey_state_e {
#define SSH_CLOSED 0x01
#define SSH_READ_PENDING 0x02
#define SSH_CLOSED_ERROR 0x04
+#define SSH_WRITE_PENDING 0x08
enum ssh_server_known_e {
SSH_SERVER_ERROR=-1,
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;
}