Skip to content

Commit 777aa34

Browse files
committed
BUG/MINOR: multiple execution of the function worker_stop() disabled
In case HAProxy is used in master-worker mode, it is possible that it sends a SIGINT signal several times in a row. Also, it may happen that the program runs out of time and immediately after that the program receives a SIGINT signal. Any of these causes led to the crash of the program. Version of the program changed to v1.2.12.
1 parent 4b32cbf commit 777aa34

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.2.11
1+
1.2.12

src/.build-counter

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2414
1+
2415

src/worker.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,26 @@ static void worker_stop_ev(int revents __maybe_unused, void *base)
349349
*/
350350
static void worker_stop(struct ev_loop *loop, const char *msg __maybe_unused)
351351
{
352-
int i;
352+
static bool_t flag_stop = 0;
353+
int i;
353354

354355
DBG_FUNC(NULL, "%p, \"%s\"", loop, msg);
355356

357+
/*
358+
* In case HAProxy is used in master-worker mode, it is possible that
359+
* it sends a SIGINT signal several times in a row. Also, it may
360+
* happen that the program runs out of time and immediately after
361+
* that the program receives a SIGINT signal. To disable this, the
362+
* variable flag_stop is used.
363+
*/
364+
if (flag_stop) {
365+
W_DBG(WORKER, NULL, " Server stopping already in progress, canceled: %s", msg);
366+
367+
return;
368+
}
369+
370+
flag_stop = 1;
371+
356372
W_DBG(WORKER, NULL, " Stopping the server, %s", msg);
357373

358374
ev_once(loop, -1, 0, 0, worker_stop_ev, loop);

0 commit comments

Comments
 (0)