nxt_main_process.c (318:c2442f5e054d) nxt_main_process.c (320:d385755599d6)
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_main.h>
8#include <nxt_runtime.h>

--- 217 unchanged lines hidden (view full) ---

226 -1, msg->port_msg.stream, 0, NULL);
227 }
228 }
229
230 nxt_mp_destroy(mp);
231}
232
233
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_main.h>
8#include <nxt_runtime.h>

--- 217 unchanged lines hidden (view full) ---

226 -1, msg->port_msg.stream, 0, NULL);
227 }
228 }
229
230 nxt_mp_destroy(mp);
231}
232
233
234static nxt_port_handler_t nxt_main_process_port_handlers[] = {
235 NULL, /* NXT_PORT_MSG_QUIT */
236 NULL, /* NXT_PORT_MSG_NEW_PORT */
237 NULL, /* NXT_PORT_MSG_CHANGE_FILE */
238 NULL, /* NXT_PORT_MSG_MMAP */
239 nxt_port_main_data_handler,
240 NULL, /* NXT_PORT_MSG_REMOVE_PID */
241 nxt_port_ready_handler,
242 nxt_port_main_start_worker_handler,
243 nxt_main_port_socket_handler,
244 nxt_main_port_modules_handler,
245 nxt_main_port_conf_store_handler,
246 nxt_port_rpc_handler,
247 nxt_port_rpc_handler,
234static nxt_port_handlers_t nxt_main_process_port_handlers = {
235 .data = nxt_port_main_data_handler,
236 .process_ready = nxt_port_process_ready_handler,
237 .start_worker = nxt_port_main_start_worker_handler,
238 .socket = nxt_main_port_socket_handler,
239 .modules = nxt_main_port_modules_handler,
240 .conf_store = nxt_main_port_conf_store_handler,
241 .rpc_ready = nxt_port_rpc_handler,
242 .rpc_error = nxt_port_rpc_handler,
248};
249
250
251static nxt_int_t
252nxt_main_process_port_create(nxt_task_t *task, nxt_runtime_t *rt)
253{
254 nxt_int_t ret;
255 nxt_port_t *port;

--- 17 unchanged lines hidden (view full) ---

273 nxt_process_port_add(task, process, port);
274
275 nxt_runtime_port_add(rt, port);
276
277 /*
278 * A main process port. A write port is not closed
279 * since it should be inherited by worker processes.
280 */
243};
244
245
246static nxt_int_t
247nxt_main_process_port_create(nxt_task_t *task, nxt_runtime_t *rt)
248{
249 nxt_int_t ret;
250 nxt_port_t *port;

--- 17 unchanged lines hidden (view full) ---

268 nxt_process_port_add(task, process, port);
269
270 nxt_runtime_port_add(rt, port);
271
272 /*
273 * A main process port. A write port is not closed
274 * since it should be inherited by worker processes.
275 */
281 nxt_port_enable(task, port, nxt_main_process_port_handlers);
276 nxt_port_enable(task, port, &nxt_main_process_port_handlers);
282
283 process->ready = 1;
284
285 return NXT_OK;
286}
287
288
289static void

--- 68 unchanged lines hidden (view full) ---

358 init = nxt_malloc(sizeof(nxt_process_init_t));
359 if (nxt_slow_path(init == NULL)) {
360 return NXT_ERROR;
361 }
362
363 init->start = nxt_controller_start;
364 init->name = "controller";
365 init->user_cred = &rt->user_cred;
277
278 process->ready = 1;
279
280 return NXT_OK;
281}
282
283
284static void

--- 68 unchanged lines hidden (view full) ---

353 init = nxt_malloc(sizeof(nxt_process_init_t));
354 if (nxt_slow_path(init == NULL)) {
355 return NXT_ERROR;
356 }
357
358 init->start = nxt_controller_start;
359 init->name = "controller";
360 init->user_cred = &rt->user_cred;
366 init->port_handlers = nxt_controller_process_port_handlers;
361 init->port_handlers = &nxt_controller_process_port_handlers;
367 init->signals = nxt_worker_process_signals;
368 init->type = NXT_PROCESS_CONTROLLER;
369 init->data = &conf;
370 init->stream = 0;
371 init->restart = 1;
372
373 ret = nxt_main_create_worker_process(task, rt, init);
374

--- 13 unchanged lines hidden (view full) ---

388 init = nxt_malloc(sizeof(nxt_process_init_t));
389 if (nxt_slow_path(init == NULL)) {
390 return NXT_ERROR;
391 }
392
393 init->start = nxt_discovery_start;
394 init->name = "discovery";
395 init->user_cred = &rt->user_cred;
362 init->signals = nxt_worker_process_signals;
363 init->type = NXT_PROCESS_CONTROLLER;
364 init->data = &conf;
365 init->stream = 0;
366 init->restart = 1;
367
368 ret = nxt_main_create_worker_process(task, rt, init);
369

--- 13 unchanged lines hidden (view full) ---

383 init = nxt_malloc(sizeof(nxt_process_init_t));
384 if (nxt_slow_path(init == NULL)) {
385 return NXT_ERROR;
386 }
387
388 init->start = nxt_discovery_start;
389 init->name = "discovery";
390 init->user_cred = &rt->user_cred;
396 init->port_handlers = nxt_discovery_process_port_handlers;
391 init->port_handlers = &nxt_discovery_process_port_handlers;
397 init->signals = nxt_worker_process_signals;
398 init->type = NXT_PROCESS_DISCOVERY;
399 init->data = rt;
400 init->stream = 0;
401 init->restart = 0;
402
403 return nxt_main_create_worker_process(task, rt, init);
404}

--- 7 unchanged lines hidden (view full) ---

412 init = nxt_malloc(sizeof(nxt_process_init_t));
413 if (nxt_slow_path(init == NULL)) {
414 return NXT_ERROR;
415 }
416
417 init->start = nxt_router_start;
418 init->name = "router";
419 init->user_cred = &rt->user_cred;
392 init->signals = nxt_worker_process_signals;
393 init->type = NXT_PROCESS_DISCOVERY;
394 init->data = rt;
395 init->stream = 0;
396 init->restart = 0;
397
398 return nxt_main_create_worker_process(task, rt, init);
399}

--- 7 unchanged lines hidden (view full) ---

407 init = nxt_malloc(sizeof(nxt_process_init_t));
408 if (nxt_slow_path(init == NULL)) {
409 return NXT_ERROR;
410 }
411
412 init->start = nxt_router_start;
413 init->name = "router";
414 init->user_cred = &rt->user_cred;
420 init->port_handlers = nxt_router_process_port_handlers;
415 init->port_handlers = &nxt_router_process_port_handlers;
421 init->signals = nxt_worker_process_signals;
422 init->type = NXT_PROCESS_ROUTER;
423 init->data = rt;
424 init->stream = 0;
425 init->restart = 1;
426
427 return nxt_main_create_worker_process(task, rt, init);
428}

--- 45 unchanged lines hidden (view full) ---

474
475 title = last;
476 end = title + app_conf->name.length + sizeof("\"\" application");
477
478 nxt_sprintf(title, end, "\"%V\" application%Z", &app_conf->name);
479
480 init->start = nxt_app_start;
481 init->name = (char *) title;
416 init->signals = nxt_worker_process_signals;
417 init->type = NXT_PROCESS_ROUTER;
418 init->data = rt;
419 init->stream = 0;
420 init->restart = 1;
421
422 return nxt_main_create_worker_process(task, rt, init);
423}

--- 45 unchanged lines hidden (view full) ---

469
470 title = last;
471 end = title + app_conf->name.length + sizeof("\"\" application");
472
473 nxt_sprintf(title, end, "\"%V\" application%Z", &app_conf->name);
474
475 init->start = nxt_app_start;
476 init->name = (char *) title;
482 init->port_handlers = nxt_app_process_port_handlers;
477 init->port_handlers = &nxt_app_process_port_handlers;
483 init->signals = nxt_worker_process_signals;
484 init->type = NXT_PROCESS_WORKER;
485 init->data = app_conf;
486 init->stream = stream;
487 init->restart = 0;
488
489 return nxt_main_create_worker_process(task, rt, init);
490}

--- 678 unchanged lines hidden ---
478 init->signals = nxt_worker_process_signals;
479 init->type = NXT_PROCESS_WORKER;
480 init->data = app_conf;
481 init->stream = stream;
482 init->restart = 0;
483
484 return nxt_main_create_worker_process(task, rt, init);
485}

--- 678 unchanged lines hidden ---