Deleted
Added
nxt_process.c (232:43f9808200cd) | nxt_process.c (240:36bafba970b5) |
---|---|
1 2/* 3 * Copyright (C) Igor Sysoev 4 * Copyright (C) NGINX, Inc. 5 */ 6 7#include <nxt_main.h> | 1 2/* 3 * Copyright (C) Igor Sysoev 4 * Copyright (C) NGINX, Inc. 5 */ 6 7#include <nxt_main.h> |
8#include <nxt_master_process.h> | 8#include <nxt_main_process.h> |
9 10 11static void nxt_process_start(nxt_task_t *task, nxt_process_t *process); 12static nxt_int_t nxt_user_groups_get(nxt_task_t *task, nxt_user_cred_t *uc); 13 14 15/* A cached process pid. */ 16nxt_pid_t nxt_pid; --- 71 unchanged lines hidden (view full) --- 88 return pid; 89} 90 91 92static void 93nxt_process_start(nxt_task_t *task, nxt_process_t *process) 94{ 95 nxt_int_t ret; | 9 10 11static void nxt_process_start(nxt_task_t *task, nxt_process_t *process); 12static nxt_int_t nxt_user_groups_get(nxt_task_t *task, nxt_user_cred_t *uc); 13 14 15/* A cached process pid. */ 16nxt_pid_t nxt_pid; --- 71 unchanged lines hidden (view full) --- 88 return pid; 89} 90 91 92static void 93nxt_process_start(nxt_task_t *task, nxt_process_t *process) 94{ 95 nxt_int_t ret; |
96 nxt_port_t *port, *master_port; | 96 nxt_port_t *port, *main_port; |
97 nxt_thread_t *thread; 98 nxt_runtime_t *rt; 99 nxt_process_init_t *init; 100 nxt_event_engine_t *engine; 101 const nxt_event_interface_t *interface; 102 103 init = process->init; 104 --- 15 unchanged lines hidden (view full) --- 120 } 121 122 rt = thread->runtime; 123 124 rt->types |= (1U << init->type); 125 126 engine = thread->engine; 127 | 97 nxt_thread_t *thread; 98 nxt_runtime_t *rt; 99 nxt_process_init_t *init; 100 nxt_event_engine_t *engine; 101 const nxt_event_interface_t *interface; 102 103 init = process->init; 104 --- 15 unchanged lines hidden (view full) --- 120 } 121 122 rt = thread->runtime; 123 124 rt->types |= (1U << init->type); 125 126 engine = thread->engine; 127 |
128 /* Update inherited master process event engine and signals processing. */ | 128 /* Update inherited main process event engine and signals processing. */ |
129 engine->signals->sigev = init->signals; 130 131 interface = nxt_service_get(rt->services, "engine", rt->engine); 132 if (nxt_slow_path(interface == NULL)) { 133 goto fail; 134 } 135 136 if (nxt_event_engine_change(engine, interface, rt->batch) != NXT_OK) { 137 goto fail; 138 } 139 140 ret = nxt_runtime_thread_pool_create(thread, rt, rt->auxiliary_threads, 141 60000 * 1000000LL); 142 if (nxt_slow_path(ret != NXT_OK)) { 143 goto fail; 144 } 145 | 129 engine->signals->sigev = init->signals; 130 131 interface = nxt_service_get(rt->services, "engine", rt->engine); 132 if (nxt_slow_path(interface == NULL)) { 133 goto fail; 134 } 135 136 if (nxt_event_engine_change(engine, interface, rt->batch) != NXT_OK) { 137 goto fail; 138 } 139 140 ret = nxt_runtime_thread_pool_create(thread, rt, rt->auxiliary_threads, 141 60000 * 1000000LL); 142 if (nxt_slow_path(ret != NXT_OK)) { 143 goto fail; 144 } 145 |
146 master_port = rt->port_by_type[NXT_PROCESS_MASTER]; | 146 main_port = rt->port_by_type[NXT_PROCESS_MAIN]; |
147 | 147 |
148 nxt_port_read_close(master_port); 149 nxt_port_write_enable(task, master_port); | 148 nxt_port_read_close(main_port); 149 nxt_port_write_enable(task, main_port); |
150 151 port = nxt_process_port_first(process); 152 153 nxt_port_write_close(port); 154 155 ret = init->start(task, init->data); 156 157 if (nxt_slow_path(ret != NXT_OK)) { 158 goto fail; 159 } 160 161 nxt_port_enable(task, port, init->port_handlers); 162 | 150 151 port = nxt_process_port_first(process); 152 153 nxt_port_write_close(port); 154 155 ret = init->start(task, init->data); 156 157 if (nxt_slow_path(ret != NXT_OK)) { 158 goto fail; 159 } 160 161 nxt_port_enable(task, port, init->port_handlers); 162 |
163 ret = nxt_port_socket_write(task, master_port, NXT_PORT_MSG_READY, | 163 ret = nxt_port_socket_write(task, main_port, NXT_PORT_MSG_READY, |
164 -1, init->stream, 0, NULL); 165 166 if (nxt_slow_path(ret != NXT_OK)) { | 164 -1, init->stream, 0, NULL); 165 166 if (nxt_slow_path(ret != NXT_OK)) { |
167 nxt_log(task, NXT_LOG_ERR, "failed to send READY message to master"); | 167 nxt_log(task, NXT_LOG_ERR, "failed to send READY message to main"); |
168 169 goto fail; 170 } 171 172 return; 173 174fail: 175 --- 239 unchanged lines hidden (view full) --- 415} 416 417 418/* 419 * nxt_user_groups_get() stores an array of groups IDs which should be 420 * set by the initgroups() function for a given user. The initgroups() 421 * may block a just forked worker process for some time if LDAP or NDIS+ 422 * is used, so nxt_user_groups_get() allows to get worker user groups in | 168 169 goto fail; 170 } 171 172 return; 173 174fail: 175 --- 239 unchanged lines hidden (view full) --- 415} 416 417 418/* 419 * nxt_user_groups_get() stores an array of groups IDs which should be 420 * set by the initgroups() function for a given user. The initgroups() 421 * may block a just forked worker process for some time if LDAP or NDIS+ 422 * is used, so nxt_user_groups_get() allows to get worker user groups in |
423 * master process. In a nutshell the initgroups() calls getgrouplist() | 423 * main process. In a nutshell the initgroups() calls getgrouplist() |
424 * followed by setgroups(). However Solaris lacks the getgrouplist(). 425 * Besides getgrouplist() does not allow to query the exact number of 426 * groups while NGROUPS_MAX can be quite large (e.g. 65536 on Linux). 427 * So nxt_user_groups_get() emulates getgrouplist(): at first the function 428 * saves the super-user groups IDs, then calls initgroups() and saves the 429 * specified user groups IDs, and then restores the super-user groups IDs. 430 * This works at least on Linux, FreeBSD, and Solaris, but does not work 431 * on MacOSX, getgroups(2): --- 229 unchanged lines hidden --- | 424 * followed by setgroups(). However Solaris lacks the getgrouplist(). 425 * Besides getgrouplist() does not allow to query the exact number of 426 * groups while NGROUPS_MAX can be quite large (e.g. 65536 on Linux). 427 * So nxt_user_groups_get() emulates getgrouplist(): at first the function 428 * saves the super-user groups IDs, then calls initgroups() and saves the 429 * specified user groups IDs, and then restores the super-user groups IDs. 430 * This works at least on Linux, FreeBSD, and Solaris, but does not work 431 * on MacOSX, getgroups(2): --- 229 unchanged lines hidden --- |