diff --git a/sbin/hastd/hast.h b/sbin/hastd/hast.h index 8c643956ea24..15bcdb542fea 100644 --- a/sbin/hastd/hast.h +++ b/sbin/hastd/hast.h @@ -98,6 +98,9 @@ #define HAST_ADDRSIZE 1024 #define HAST_TOKEN_SIZE 16 +/* Number of seconds to sleep between reconnect retries or keepalive packets. */ +#define HAST_KEEPALIVE 10 + struct hastd_config { /* Address to communicate with hastctl(8). */ char hc_controladdr[HAST_ADDRSIZE]; diff --git a/sbin/hastd/primary.c b/sbin/hastd/primary.c index 6246c710b583..c9266e544925 100644 --- a/sbin/hastd/primary.c +++ b/sbin/hastd/primary.c @@ -150,10 +150,6 @@ static pthread_mutex_t metadata_lock; * and remote components. */ #define HAST_NCOMPONENTS 2 -/* - * Number of seconds to sleep between reconnect retries or keepalive packets. - */ -#define RETRY_SLEEP 10 #define ISCONNECTED(res, no) \ ((res)->hr_remotein != NULL && (res)->hr_remoteout != NULL) @@ -1318,10 +1314,10 @@ remote_send_thread(void *arg) for (;;) { pjdlog_debug(2, "remote_send: Taking request."); - QUEUE_TAKE1(hio, send, ncomp, RETRY_SLEEP); + QUEUE_TAKE1(hio, send, ncomp, HAST_KEEPALIVE); if (hio == NULL) { now = time(NULL); - if (lastcheck + RETRY_SLEEP <= now) { + if (lastcheck + HAST_KEEPALIVE <= now) { keepalive_send(res, ncomp); lastcheck = now; } @@ -2098,7 +2094,7 @@ guard_thread(void *arg) PJDLOG_VERIFY(sigaddset(&mask, SIGINT) == 0); PJDLOG_VERIFY(sigaddset(&mask, SIGTERM) == 0); - timeout.tv_sec = RETRY_SLEEP; + timeout.tv_sec = HAST_KEEPALIVE; timeout.tv_nsec = 0; signo = -1; @@ -2116,7 +2112,7 @@ guard_thread(void *arg) pjdlog_debug(2, "remote_guard: Checking connections."); now = time(NULL); - if (lastcheck + RETRY_SLEEP <= now) { + if (lastcheck + HAST_KEEPALIVE <= now) { for (ii = 0; ii < ncomps; ii++) guard_one(res, ii); lastcheck = now; diff --git a/sbin/hastd/secondary.c b/sbin/hastd/secondary.c index 46fa6f33a661..218c8023df1d 100644 --- a/sbin/hastd/secondary.c +++ b/sbin/hastd/secondary.c @@ -418,7 +418,7 @@ hastd_secondary(struct hast_resource *res, struct nv *nvin) PJDLOG_VERIFY(sigprocmask(SIG_SETMASK, &mask, NULL) == 0); /* Error in setting timeout is not critical, but why should it fail? */ - if (proto_timeout(res->hr_remotein, 0) < 0) + if (proto_timeout(res->hr_remotein, 2 * HAST_KEEPALIVE) < 0) pjdlog_errno(LOG_WARNING, "Unable to set connection timeout"); if (proto_timeout(res->hr_remoteout, res->hr_timeout) < 0) pjdlog_errno(LOG_WARNING, "Unable to set connection timeout");