Refactor of process management.
The process abstraction has changed to: setup(task, process) start(task, process_data) prefork(task, process, mp) The prefork() occurs in the main process right before fork. The file src/nxt_main_process.c is completely free of process specific logic. The creation of a process now supports a PROCESS_CREATED state. The The setup() function of each process can set its state to either created or ready. If created, a MSG_PROCESS_CREATED is sent to main process, where external setup can be done (required for rootfs under container). The core processes (discovery, controller and router) doesn't need external setup, then they all proceeds to their start() function straight away. In the case of applications, the load of the module happens at the process setup() time and The module's init() function has changed to be the start() of the process. The module API has changed to: setup(task, process, conf) start(task, data) As a direct benefit of the PROCESS_CREATED message, the clone(2) of processes using pid namespaces now doesn't need to create a pipe to make the child block until parent setup uid/gid mappings nor it needs to receive the child pid.
This commit is contained in:
@@ -65,7 +65,8 @@ typedef struct {
|
||||
PyObject_HEAD
|
||||
} nxt_py_error_t;
|
||||
|
||||
static nxt_int_t nxt_python_init(nxt_task_t *task, nxt_common_app_conf_t *conf);
|
||||
static nxt_int_t nxt_python_start(nxt_task_t *task,
|
||||
nxt_process_data_t *data);
|
||||
static nxt_int_t nxt_python_init_strings(void);
|
||||
static void nxt_python_request_handler(nxt_unit_request_info_t *req);
|
||||
static void nxt_python_atexit(void);
|
||||
@@ -116,7 +117,7 @@ NXT_EXPORT nxt_app_module_t nxt_app_module = {
|
||||
nxt_string("python"),
|
||||
PY_VERSION,
|
||||
NULL,
|
||||
nxt_python_init,
|
||||
nxt_python_start,
|
||||
};
|
||||
|
||||
|
||||
@@ -211,7 +212,7 @@ static nxt_python_string_t nxt_python_strings[] = {
|
||||
|
||||
|
||||
static nxt_int_t
|
||||
nxt_python_init(nxt_task_t *task, nxt_common_app_conf_t *conf)
|
||||
nxt_python_start(nxt_task_t *task, nxt_process_data_t *data)
|
||||
{
|
||||
int rc;
|
||||
char *nxt_py_module;
|
||||
@@ -219,6 +220,7 @@ nxt_python_init(nxt_task_t *task, nxt_common_app_conf_t *conf)
|
||||
PyObject *obj, *pypath, *module;
|
||||
nxt_unit_ctx_t *unit_ctx;
|
||||
nxt_unit_init_t python_init;
|
||||
nxt_common_app_conf_t *app_conf;
|
||||
nxt_python_app_conf_t *c;
|
||||
#if PY_MAJOR_VERSION == 3
|
||||
char *path;
|
||||
@@ -229,7 +231,8 @@ nxt_python_init(nxt_task_t *task, nxt_common_app_conf_t *conf)
|
||||
static const char bin_python[] = "/bin/python";
|
||||
#endif
|
||||
|
||||
c = &conf->u.python;
|
||||
app_conf = data->app;
|
||||
c = &app_conf->u.python;
|
||||
|
||||
if (c->module.length == 0) {
|
||||
nxt_alert(task, "python module is empty");
|
||||
@@ -410,7 +413,7 @@ nxt_python_init(nxt_task_t *task, nxt_common_app_conf_t *conf)
|
||||
nxt_unit_default_init(task, &python_init);
|
||||
|
||||
python_init.callbacks.request_handler = nxt_python_request_handler;
|
||||
python_init.shm_limit = conf->shm_limit;
|
||||
python_init.shm_limit = data->app->shm_limit;
|
||||
|
||||
unit_ctx = nxt_unit_init(&python_init);
|
||||
if (nxt_slow_path(unit_ctx == NULL)) {
|
||||
|
||||
Reference in New Issue
Block a user