aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2013-11-03 12:46:27 +0100
committerAndreas Schneider <asn@cryptomilk.org>2013-11-03 12:46:27 +0100
commit04cb94a2ddb091c82764ed2b3981f891b093d5d3 (patch)
treeeac65da46a18cd8bbb3334ac577fcc0bd6fb9048
parent754152aa2244fef75a8e7ed2d97df5bb2a09546c (diff)
downloadlibssh-04cb94a2ddb091c82764ed2b3981f891b093d5d3.tar.gz
libssh-04cb94a2ddb091c82764ed2b3981f891b093d5d3.tar.xz
libssh-04cb94a2ddb091c82764ed2b3981f891b093d5d3.zip
socket: Fix check for pending data.
BUG: https://red.libssh.org/issues/119 Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
-rw-r--r--include/libssh/libssh.h6
-rw-r--r--src/socket.c6
2 files changed, 8 insertions, 4 deletions
diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h
index a451620e..84d05937 100644
--- a/include/libssh/libssh.h
+++ b/include/libssh/libssh.h
@@ -208,10 +208,14 @@ enum ssh_publickey_state_e {
SSH_PUBLICKEY_STATE_WRONG=2
};
-/* status flags */
+/* Status flags */
+/** Socket is closed */
#define SSH_CLOSED 0x01
+/** Reading to socket won't block */
#define SSH_READ_PENDING 0x02
+/** Session was closed due to an error */
#define SSH_CLOSED_ERROR 0x04
+/** Output buffer not empty */
#define SSH_WRITE_PENDING 0x08
enum ssh_server_known_e {
diff --git a/src/socket.c b/src/socket.c
index 0dbbe2bc..c76ef5ae 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -695,11 +695,11 @@ int ssh_socket_buffered_write_bytes(ssh_socket s){
int ssh_socket_get_status(ssh_socket s) {
int r = 0;
- if (s->read_wontblock) {
- r |= SSH_READ_PENDING;
+ if (buffer_get_len(s->in_buffer) > 0) {
+ r |= SSH_READ_PENDING;
}
- if (s->write_wontblock) {
+ if (buffer_get_len(s->out_buffer) > 0) {
r |= SSH_WRITE_PENDING;
}