1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-12-02 01:17:52 +03:00

socket: Add a SSH_WRITE_PENDING socket status.

This commit is contained in:
Andreas Schneider
2012-07-17 18:03:34 +02:00
parent 8ef45e00c7
commit 43e3a8e497
3 changed files with 12 additions and 3 deletions

View File

@@ -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,

View File

@@ -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;
}

View File

@@ -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;
}