Skip to content
Snippets Groups Projects
Commit 9977fa58 authored by Georgy Moshkin's avatar Georgy Moshkin :speech_balloon: Committed by Дмитрий Кольцов
Browse files

fix(picodata): fix graceful stopping

Was broken because `tarantool_free` checks if the current process is the
main one and not the child, which was forked at some point (at what
point?). This check was implemented by saving the original process's id
in the static variable master_pid, which got set when the code got
loaded the first time into memory.

So we broke this when we started forking the process in picodata, which
resulted in `master_pid` being set to the pid of the picodata's
"supervisor" process, which doesn't even enter tarantool runtime.

The fix is simple - save master_pid first thing when running
tarantool_main.
parent 5766d96d
No related branches found
No related tags found
No related merge requests found
......@@ -89,7 +89,7 @@
#include "core/clock_lowres.h"
#include "lua/utils.h"
static pid_t master_pid = getpid();
static pid_t master_pid = -1;
static struct pidfh *pid_file_handle;
static char *script = NULL;
static char *pid_file = NULL;
......@@ -642,6 +642,10 @@ extern "C"
int
tarantool_main(int argc, char **argv, void (*cb)(void *), void *cb_data)
{
// Picodata forks the process and only the child runs tarantool_main.
// Therefore master_pid must be set here instead of the static memory,
// so that the resources are cleaned up at the end
master_pid = getpid();
/* set locale to make iswXXXX function work */
if (setlocale(LC_CTYPE, "C.UTF-8") == NULL &&
setlocale(LC_CTYPE, "en_US.UTF-8") == NULL &&
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment