aboutsummaryrefslogtreecommitdiff
path: root/src/poll.c
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2011-05-24 23:26:18 +0200
committerAris Adamantiadis <aris@0xbadc0de.be>2011-05-24 23:26:18 +0200
commit59f7647cd97c62ab7a26725e5a166dcb54b27bc6 (patch)
tree34dad1189e803af0b8d1d3caa83cd220a950bc3f /src/poll.c
parent4d6b1aa2c7ea67d6909680254b7ae68aa437a6ef (diff)
downloadlibssh-59f7647cd97c62ab7a26725e5a166dcb54b27bc6.tar.gz
libssh-59f7647cd97c62ab7a26725e5a166dcb54b27bc6.tar.xz
libssh-59f7647cd97c62ab7a26725e5a166dcb54b27bc6.zip
Introduced ssh_timeout_elapsed functions
Functions to mesure elapsed time before and after a serie of calls. Introduces a dependancy to clock_gettime() and librt, hope this doesn't break anything. Porting to gettimeofday() should not be too hard.
Diffstat (limited to 'src/poll.c')
-rw-r--r--src/poll.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/poll.c b/src/poll.c
index 55e23a81..f294a454 100644
--- a/src/poll.c
+++ b/src/poll.c
@@ -589,6 +589,7 @@ void ssh_poll_ctx_remove(ssh_poll_ctx ctx, ssh_poll_handle p) {
* the poll() function.
* @returns SSH_OK No error.
* SSH_ERROR Error happened during the poll.
+ * SSH_AGAIN Timeout occured
*/
int ssh_poll_ctx_dopoll(ssh_poll_ctx ctx, int timeout) {
@@ -602,8 +603,10 @@ int ssh_poll_ctx_dopoll(ssh_poll_ctx ctx, int timeout) {
return 0;
rc = ssh_poll(ctx->pollfds, ctx->polls_used, timeout);
- if(rc <= 0)
+ if(rc < 0)
return SSH_ERROR;
+ if (rc == 0)
+ return SSH_AGAIN;
used = ctx->polls_used;
for (i = 0; i < used && rc > 0; ) {
if (!ctx->pollfds[i].revents) {