server session CHANGE ssh channel polling fixed
diff --git a/src/session_server.c b/src/session_server.c
index 08919a4..deed600 100644
--- a/src/session_server.c
+++ b/src/session_server.c
@@ -732,20 +732,17 @@
ps->pfds[i].revents = 0;
if (i == ps->session_count - 1) {
/* last session and it is not the right channel, ... */
- if (timeout > 0) {
- /* ... decrease timeout, wait it all out and try again, last time */
- nc_subtract_elapsed(&timeout, &old_ts);
- usleep(timeout * 1000);
- timeout = 0;
- goto retry_poll;
- } else if (!timeout) {
+ if (!timeout) {
/* ... timeout is 0, so that is it */
return 0;
- } else {
- /* ... retry polling reasonable time apart */
- usleep(NC_TIMEOUT_STEP);
- goto retry_poll;
}
+ /* ... retry polling reasonable time apart ... */
+ usleep(NC_TIMEOUT_STEP);
+ if (timeout > 0) {
+ /* ... and decrease timeout, if not -1 */
+ nc_subtract_elapsed(&timeout, &old_ts);
+ }
+ goto retry_poll;
}
/* check other sessions */
continue;
diff --git a/src/session_server.h b/src/session_server.h
index dd74480..d5abf9e 100644
--- a/src/session_server.h
+++ b/src/session_server.h
@@ -186,7 +186,7 @@
* parsed into session ctx),
* 2 if an RPC was processed and there are unhandled events on other sessions,
* 3 if a session from \p ps changed its status (was invalidated),
- * -1 on error.
+ * -1 on error (a session likely changed its status as well).
*
* Only with SSH support:
* 4 if an SSH message was processed,