From 7ec798d3e73f3dac94a3c240545ebaf4daa189b4 Mon Sep 17 00:00:00 2001 From: Seb Boving Date: Wed, 18 Feb 2015 12:51:45 -0800 Subject: Locally restart ssh_poll() upon EINTR. BUG: https://red.libssh.org/issues/186 Reviewed-by: Aris Adamantiadis Signed-off-by: Sebastien Boving --- src/poll.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/poll.c b/src/poll.c index 4e9f19f0..dfa687a9 100644 --- a/src/poll.c +++ b/src/poll.c @@ -597,11 +597,17 @@ int ssh_poll_ctx_dopoll(ssh_poll_ctx ctx, int timeout) { ssh_poll_handle p; socket_t fd; int revents; + struct ssh_timestamp ts; if (!ctx->polls_used) return SSH_ERROR; - rc = ssh_poll(ctx->pollfds, ctx->polls_used, timeout); + ssh_timestamp_init(&ts); + do { + int tm = ssh_timeout_update(&ts, timeout); + rc = ssh_poll(ctx->pollfds, ctx->polls_used, tm); + } while (rc == -1 && errno == EINTR); + if(rc < 0) return SSH_ERROR; if (rc == 0) -- cgit v1.2.3