nxt_main_process.c (342:82c2825a617a) nxt_main_process.c (343:9fa845db60fb)
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_main.h>
8#include <nxt_runtime.h>

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

255 return NXT_ERROR;
256 }
257
258 port = nxt_port_new(task, 0, nxt_pid, NXT_PROCESS_MAIN);
259 if (nxt_slow_path(port == NULL)) {
260 return NXT_ERROR;
261 }
262
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_main.h>
8#include <nxt_runtime.h>

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

255 return NXT_ERROR;
256 }
257
258 port = nxt_port_new(task, 0, nxt_pid, NXT_PROCESS_MAIN);
259 if (nxt_slow_path(port == NULL)) {
260 return NXT_ERROR;
261 }
262
263 nxt_process_port_add(task, process, port);
264
263 ret = nxt_port_socket_init(task, port, 0);
264 if (nxt_slow_path(ret != NXT_OK)) {
265 ret = nxt_port_socket_init(task, port, 0);
266 if (nxt_slow_path(ret != NXT_OK)) {
267 nxt_port_use(task, port, -1);
265 return ret;
266 }
267
268 return ret;
269 }
270
268 nxt_process_port_add(task, process, port);
271 nxt_runtime_port_add(task, port);
269
272
270 nxt_runtime_port_add(rt, port);
273 nxt_port_use(task, port, -1);
271
272 /*
273 * A main process port. A write port is not closed
274 * since it should be inherited by worker processes.
275 */
276 nxt_port_enable(task, port, &nxt_main_process_port_handlers);
277
278 process->ready = 1;

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

503 if (nxt_slow_path(process == NULL)) {
504 return NXT_ERROR;
505 }
506
507 process->init = init;
508
509 port = nxt_port_new(task, 0, 0, init->type);
510 if (nxt_slow_path(port == NULL)) {
274
275 /*
276 * A main process port. A write port is not closed
277 * since it should be inherited by worker processes.
278 */
279 nxt_port_enable(task, port, &nxt_main_process_port_handlers);
280
281 process->ready = 1;

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

506 if (nxt_slow_path(process == NULL)) {
507 return NXT_ERROR;
508 }
509
510 process->init = init;
511
512 port = nxt_port_new(task, 0, 0, init->type);
513 if (nxt_slow_path(port == NULL)) {
511 nxt_runtime_process_remove(rt, process);
514 nxt_runtime_process_remove(task, process);
512 return NXT_ERROR;
513 }
514
515 nxt_process_port_add(task, process, port);
516
517 ret = nxt_port_socket_init(task, port, 0);
518 if (nxt_slow_path(ret != NXT_OK)) {
515 return NXT_ERROR;
516 }
517
518 nxt_process_port_add(task, process, port);
519
520 ret = nxt_port_socket_init(task, port, 0);
521 if (nxt_slow_path(ret != NXT_OK)) {
519 nxt_mp_release(port->mem_pool, port);
522 nxt_port_use(task, port, -1);
520 return ret;
521 }
522
523 pid = nxt_process_create(task, process);
524
523 return ret;
524 }
525
526 pid = nxt_process_create(task, process);
527
528 nxt_port_use(task, port, -1);
529
525 switch (pid) {
526
527 case -1:
528 return NXT_ERROR;
529
530 case 0:
531 /* A worker process, return to the event engine work queue loop. */
532 return NXT_AGAIN;

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

750
751 rt = task->thread->runtime;
752
753 process = nxt_runtime_process_find(rt, pid);
754
755 if (process) {
756 init = process->init;
757
530 switch (pid) {
531
532 case -1:
533 return NXT_ERROR;
534
535 case 0:
536 /* A worker process, return to the event engine work queue loop. */
537 return NXT_AGAIN;

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

755
756 rt = task->thread->runtime;
757
758 process = nxt_runtime_process_find(rt, pid);
759
760 if (process) {
761 init = process->init;
762
758 nxt_runtime_process_remove(rt, process);
763 nxt_runtime_process_remove(task, process);
759
760 if (!nxt_exiting) {
761 nxt_runtime_process_each(rt, process) {
762
763 if (process->pid == nxt_pid
764 || process->pid == pid
765 || nxt_queue_is_empty(&process->ports))
766 {

--- 400 unchanged lines hidden ---
764
765 if (!nxt_exiting) {
766 nxt_runtime_process_each(rt, process) {
767
768 if (process->pid == nxt_pid
769 || process->pid == pid
770 || nxt_queue_is_empty(&process->ports))
771 {

--- 400 unchanged lines hidden ---