Skip to content

Commit

Permalink
BUG/MINOR: multiple execution of the function worker_stop() disabled
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
zaga00 committed Jul 13, 2020
1 parent 4b32cbf commit 777aa34
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
1.2.11
1.2.12
2 changes: 1 addition & 1 deletion src/.build-counter
@@ -1 +1 @@
2414
2415
18 changes: 17 additions & 1 deletion src/worker.c
Expand Up @@ -349,10 +349,26 @@ static void worker_stop_ev(int revents __maybe_unused, void *base)
*/
static void worker_stop(struct ev_loop *loop, const char *msg __maybe_unused)
{
int i;
static bool_t flag_stop = 0;
int i;

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

/*
* 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. To disable this, the
* variable flag_stop is used.
*/
if (flag_stop) {
W_DBG(WORKER, NULL, " Server stopping already in progress, canceled: %s", msg);

return;
}

flag_stop = 1;

W_DBG(WORKER, NULL, " Stopping the server, %s", msg);

ev_once(loop, -1, 0, 0, worker_stop_ev, loop);
Expand Down

0 comments on commit 777aa34

Please sign in to comment.