From 1b8dcdd76275c1a5071a844becc8c3d6e9daae16 Mon Sep 17 00:00:00 2001 From: Nate Straz Date: Fri, 11 Aug 2006 18:54:04 +0000 Subject: After doing some debugging with the fleas, it turns out we're not waiting around long enough for the heartbeat response to come back. Since we only heartbeat when there isn't any output (in qarsh), taking up to a second won't hurt. After doing some tests I'm changing the recvfrom to recvfrom sleep to 1000 usec and retrying up to 40 times. --- btime.c | 4 ++-- btime_int.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/btime.c b/btime.c index 9deca7d..ad1569f 100644 --- a/btime.c +++ b/btime.c @@ -96,7 +96,7 @@ btime(const char *host) if ((nbytes = recvfrom(sd, &response, BTIME_MSGLEN, MSG_DONTWAIT, (struct sockaddr *)&resp_addr, &resp_addr_len)) < 0) { if (errno == EAGAIN) { - usleep(retry * 100); + usleep(RETRY_SLEEP); continue; } else { /* Non EAGAIN error... */ @@ -113,7 +113,7 @@ btime(const char *host) btime = strtoul(response+COOKIE_LEN, NULL, 10); break; } else { - fprintf(stderr, "Ignoring invalid cookie\n"); + /* ignore the invalid btime cookie */ continue; } } else if (!same_addr(&serv_addr, &resp_addr)) { diff --git a/btime_int.h b/btime_int.h index 38f043f..817df1c 100644 --- a/btime_int.h +++ b/btime_int.h @@ -7,7 +7,8 @@ #define BTIME_PORT 23456 #define BTIME_MSGLEN 128 -#define MAX_RETRY 5 +#define MAX_RETRY 40 +#define RETRY_SLEEP 1000 #define COOKIE_RANDOM_PARTS 4 #define COOKIE_LEN (3 + (COOKIE_RANDOM_PARTS * sizeof(int32_t))) -- cgit