diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libc/net/rcmd.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/lib/libc/net/rcmd.c b/src/lib/libc/net/rcmd.c index 5ef4404001..600565a235 100644 --- a/src/lib/libc/net/rcmd.c +++ b/src/lib/libc/net/rcmd.c | |||
| @@ -45,6 +45,7 @@ | |||
| 45 | #include <ctype.h> | 45 | #include <ctype.h> |
| 46 | #include <string.h> | 46 | #include <string.h> |
| 47 | #include <syslog.h> | 47 | #include <syslog.h> |
| 48 | #include <time.h> | ||
| 48 | #include <stdlib.h> | 49 | #include <stdlib.h> |
| 49 | #include <poll.h> | 50 | #include <poll.h> |
| 50 | 51 | ||
| @@ -66,7 +67,8 @@ rcmd_af(char **ahost, int porta, const char *locuser, const char *remuser, | |||
| 66 | struct sockaddr_storage from; | 67 | struct sockaddr_storage from; |
| 67 | sigset_t oldmask, mask; | 68 | sigset_t oldmask, mask; |
| 68 | pid_t pid; | 69 | pid_t pid; |
| 69 | int s, lport, timo; | 70 | int s, lport; |
| 71 | struct timespec timo; | ||
| 70 | char c, *p; | 72 | char c, *p; |
| 71 | int refused; | 73 | int refused; |
| 72 | in_port_t rport = porta; | 74 | in_port_t rport = porta; |
| @@ -110,10 +112,11 @@ rcmd_af(char **ahost, int porta, const char *locuser, const char *remuser, | |||
| 110 | 112 | ||
| 111 | r = res; | 113 | r = res; |
| 112 | refused = 0; | 114 | refused = 0; |
| 115 | timespecclear(&timo); | ||
| 113 | sigemptyset(&mask); | 116 | sigemptyset(&mask); |
| 114 | sigaddset(&mask, SIGURG); | 117 | sigaddset(&mask, SIGURG); |
| 115 | sigprocmask(SIG_BLOCK, &mask, &oldmask); | 118 | sigprocmask(SIG_BLOCK, &mask, &oldmask); |
| 116 | for (timo = 1, lport = IPPORT_RESERVED - 1;;) { | 119 | for (timo.tv_sec = 1, lport = IPPORT_RESERVED - 1;;) { |
| 117 | s = rresvport_af(&lport, r->ai_family); | 120 | s = rresvport_af(&lport, r->ai_family); |
| 118 | if (s < 0) { | 121 | if (s < 0) { |
| 119 | if (errno == EAGAIN) | 122 | if (errno == EAGAIN) |
| @@ -161,9 +164,9 @@ rcmd_af(char **ahost, int porta, const char *locuser, const char *remuser, | |||
| 161 | (void)fprintf(stderr, "Trying %s...\n", hbuf); | 164 | (void)fprintf(stderr, "Trying %s...\n", hbuf); |
| 162 | continue; | 165 | continue; |
| 163 | } | 166 | } |
| 164 | if (refused && timo <= 16) { | 167 | if (refused && timo.tv_sec <= 16) { |
| 165 | (void)sleep(timo); | 168 | (void)nanosleep(&timo, NULL); |
| 166 | timo *= 2; | 169 | timo.tv_sec *= 2; |
| 167 | r = res; | 170 | r = res; |
| 168 | refused = 0; | 171 | refused = 0; |
| 169 | continue; | 172 | continue; |
