nxt_runtime.c (1997:a8a3f1d243ee) nxt_runtime.c (1998:c8790d2a89bb)
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) Valentin V. Bartenev
5 * Copyright (C) NGINX, Inc.
6 */
7
8#include <nxt_main.h>

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

35static nxt_int_t nxt_runtime_pid_file_create(nxt_task_t *task,
36 nxt_file_name_t *pid_file);
37static void nxt_runtime_thread_pool_destroy(nxt_task_t *task, nxt_runtime_t *rt,
38 nxt_runtime_cont_t cont);
39static void nxt_runtime_thread_pool_init(void);
40static void nxt_runtime_thread_pool_exit(nxt_task_t *task, void *obj,
41 void *data);
42static nxt_process_t *nxt_runtime_process_get(nxt_runtime_t *rt, nxt_pid_t pid);
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) Valentin V. Bartenev
5 * Copyright (C) NGINX, Inc.
6 */
7
8#include <nxt_main.h>

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

35static nxt_int_t nxt_runtime_pid_file_create(nxt_task_t *task,
36 nxt_file_name_t *pid_file);
37static void nxt_runtime_thread_pool_destroy(nxt_task_t *task, nxt_runtime_t *rt,
38 nxt_runtime_cont_t cont);
39static void nxt_runtime_thread_pool_init(void);
40static void nxt_runtime_thread_pool_exit(nxt_task_t *task, void *obj,
41 void *data);
42static nxt_process_t *nxt_runtime_process_get(nxt_runtime_t *rt, nxt_pid_t pid);
43static void nxt_runtime_process_remove(nxt_runtime_t *rt,
44 nxt_process_t *process);
45static void nxt_runtime_port_add(nxt_task_t *task, nxt_port_t *port);
46
47
48nxt_int_t
49nxt_runtime_create(nxt_task_t *task)
50{
51 nxt_mp_t *mp;
52 nxt_int_t ret;

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

499 nxt_port_t *port;
500 nxt_process_t *process;
501 nxt_process_init_t *init;
502
503 nxt_runtime_process_each(rt, process) {
504
505 init = nxt_process_init(process);
506
43static void nxt_runtime_port_add(nxt_task_t *task, nxt_port_t *port);
44
45
46nxt_int_t
47nxt_runtime_create(nxt_task_t *task)
48{
49 nxt_mp_t *mp;
50 nxt_int_t ret;

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

497 nxt_port_t *port;
498 nxt_process_t *process;
499 nxt_process_init_t *init;
500
501 nxt_runtime_process_each(rt, process) {
502
503 init = nxt_process_init(process);
504
507 if (init->type == NXT_PROCESS_APP) {
505 if (init->type == NXT_PROCESS_APP
506 || init->type == NXT_PROCESS_PROTOTYPE)
507 {
508
509 nxt_process_port_each(process, port) {
510
511 (void) nxt_port_socket_write(task, port, NXT_PORT_MSG_QUIT, -1,
512 0, 0, NULL);
513
514 } nxt_process_port_loop;
515 }

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

523{
524 nxt_port_t *port;
525 nxt_process_t *process;
526
527 nxt_runtime_process_each(rt, process) {
528
529 nxt_process_port_each(process, port) {
530
508
509 nxt_process_port_each(process, port) {
510
511 (void) nxt_port_socket_write(task, port, NXT_PORT_MSG_QUIT, -1,
512 0, 0, NULL);
513
514 } nxt_process_port_loop;
515 }

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

523{
524 nxt_port_t *port;
525 nxt_process_t *process;
526
527 nxt_runtime_process_each(rt, process) {
528
529 nxt_process_port_each(process, port) {
530
531 nxt_debug(task, "%d sending quit to %PI", rt->type, port->pid);
532
531 (void) nxt_port_socket_write(task, port, NXT_PORT_MSG_QUIT, -1, 0,
532 0, NULL);
533
534 } nxt_process_port_loop;
535
536 } nxt_runtime_process_loop;
537}
538

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

1384
1385 return NXT_OK;
1386}
1387
1388
1389void
1390nxt_runtime_process_release(nxt_runtime_t *rt, nxt_process_t *process)
1391{
533 (void) nxt_port_socket_write(task, port, NXT_PORT_MSG_QUIT, -1, 0,
534 0, NULL);
535
536 } nxt_process_port_loop;
537
538 } nxt_runtime_process_loop;
539}
540

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

1386
1387 return NXT_OK;
1388}
1389
1390
1391void
1392nxt_runtime_process_release(nxt_runtime_t *rt, nxt_process_t *process)
1393{
1394 nxt_process_t *child;
1395
1392 if (process->registered == 1) {
1393 nxt_runtime_process_remove(rt, process);
1394 }
1395
1396 if (process->registered == 1) {
1397 nxt_runtime_process_remove(rt, process);
1398 }
1399
1400 if (process->link.next != NULL) {
1401 nxt_queue_remove(&process->link);
1402 }
1403
1404 nxt_queue_each(child, &process->children, nxt_process_t, link) {
1405 nxt_queue_remove(&child->link);
1406 child->link.next = NULL;
1407 } nxt_queue_loop;
1408
1396 nxt_assert(process->use_count == 0);
1397 nxt_assert(process->registered == 0);
1398
1399 nxt_port_mmaps_destroy(&process->incoming, 1);
1400
1401 nxt_thread_mutex_destroy(&process->incoming.mutex);
1402
1403 /* processes from nxt_runtime_process_get() have no memory pool */

--- 299 unchanged lines hidden ---
1409 nxt_assert(process->use_count == 0);
1410 nxt_assert(process->registered == 0);
1411
1412 nxt_port_mmaps_destroy(&process->incoming, 1);
1413
1414 nxt_thread_mutex_destroy(&process->incoming.mutex);
1415
1416 /* processes from nxt_runtime_process_get() have no memory pool */

--- 299 unchanged lines hidden ---