diff options
author | Michał Łyszczek <michal.lyszczek@bofc.pl> | 2018-11-08 16:52:44 +0100 |
---|---|---|
committer | Michał Łyszczek <michal.lyszczek@bofc.pl> | 2018-11-08 16:52:44 +0100 |
commit | 0d814dd4f7333a3c7326f2495d4191798843e5a2 (patch) | |
tree | c41a6fd9ca47a729d1fd5cca97896b788beb38d8 | |
parent | 52d90d2bcbba6517fd14ae2b4000c3f558aa7907 (diff) | |
download | librb-0d814dd4f7333a3c7326f2495d4191798843e5a2.tar.gz librb-0d814dd4f7333a3c7326f2495d4191798843e5a2.tar.bz2 librb-0d814dd4f7333a3c7326f2495d4191798843e5a2.zip |
wait more time for server to set up in tests
-rw-r--r-- | tests.c | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -753,6 +753,8 @@ static void *client(void *arg) { struct sockaddr_in saddr; int fd; + const int max_timeout = 5; + int timeout_count; memset(&saddr, 0x00, sizeof(saddr)); saddr.sin_addr.s_addr = htonl(0x7f000001ul); /* 127.0.0.1 */ @@ -765,7 +767,7 @@ static void *client(void *arg) return NULL; } - for (;;) + for (timeout_count = 0;;) { if (connect(fd, (struct sockaddr *)&saddr, sizeof(saddr)) != 0) { @@ -774,7 +776,16 @@ static void *client(void *arg) continue; } - perror("socket()"); + if (errno == ETIMEDOUT) + { + if (timeout_count++ < max_timeout) + { + fprintf(stderr, "connect timed out, again\n"); + continue; + } + } + + perror("connect()"); close(fd); return NULL; } |