mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-13 14:40:22 +00:00
For secondary, set 2 * HAST_KEEPALIVE seconds timeout for incoming
connection so the worker will exit if it does not receive packets from the primary during this interval. Reported by: Christian Vogt <Christian.Vogt@haw-hamburg.de> Tested by: Christian Vogt <Christian.Vogt@haw-hamburg.de> Approved by: pjd (mentor) MFC after: 1 week
This commit is contained in:
parent
1706df7cfa
commit
8d7dcf14ff
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=219721
@ -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];
|
||||
|
@ -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;
|
||||
|
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user