mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-12-02 01:17:52 +03:00
Add ssh_get_poll_flags()
For integration with an external mainloop, we need to know how to replicate libssh's internal poll() calls. We originally through ssh_get_status() was that API, but it's not really - those flags only get updated from the *result* of a poll(), where what we really need is to know how libssh would *start* a poll(). Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
committed by
Andreas Schneider
parent
a8dc67ded8
commit
4cc7f4ad03
11
src/socket.c
11
src/socket.c
@@ -710,6 +710,17 @@ int ssh_socket_get_status(ssh_socket s) {
|
||||
return r;
|
||||
}
|
||||
|
||||
int ssh_socket_get_poll_flags(ssh_socket s) {
|
||||
int r = 0;
|
||||
if (s->poll_in != NULL && (ssh_poll_get_events (s->poll_in) & POLLIN) > 0) {
|
||||
r |= SSH_READ_PENDING;
|
||||
}
|
||||
if (s->poll_out != NULL && (ssh_poll_get_events (s->poll_out) & POLLOUT) > 0) {
|
||||
r |= SSH_WRITE_PENDING;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
int ssh_socket_set_nonblocking(socket_t fd) {
|
||||
u_long nonblocking = 1;
|
||||
|
||||
Reference in New Issue
Block a user