nxt_main_process.c (1488:6976d36be926) nxt_main_process.c (1489:4a3ec07f4b19)
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_main.h>
8#include <nxt_runtime.h>
9#include <nxt_port.h>
10#include <nxt_main_process.h>
11#include <nxt_conf.h>
12#include <nxt_router.h>
13#if (NXT_TLS)
14#include <nxt_cert.h>
15#endif
16
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_main.h>
8#include <nxt_runtime.h>
9#include <nxt_port.h>
10#include <nxt_main_process.h>
11#include <nxt_conf.h>
12#include <nxt_router.h>
13#if (NXT_TLS)
14#include <nxt_cert.h>
15#endif
16
17#include <sys/mount.h>
17
18
19
18typedef struct {
19 nxt_socket_t socket;
20 nxt_socket_error_t error;
21 u_char *start;
22 u_char *end;
23} nxt_listening_socket_t;
24
25

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

864
865 rt = task->thread->runtime;
866
867 process = nxt_runtime_process_find(rt, pid);
868 if (!process) {
869 return;
870 }
871
20typedef struct {
21 nxt_socket_t socket;
22 nxt_socket_error_t error;
23 u_char *start;
24 u_char *end;
25} nxt_listening_socket_t;
26
27

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

866
867 rt = task->thread->runtime;
868
869 process = nxt_runtime_process_find(rt, pid);
870 if (!process) {
871 return;
872 }
873
874#if (NXT_HAVE_ISOLATION_ROOTFS)
875 if (process->isolation.rootfs != NULL && process->isolation.mounts) {
876 (void) nxt_process_unmount_all(task, process);
877 }
878#endif
879
872 name = process->name;
873 stream = process->stream;
874 init = *((nxt_process_init_t *) nxt_process_init(process));
875
876 if (process->state == NXT_PROCESS_STATE_READY) {
877 process->stream = 0;
878 }
879

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

1127 {
1128 nxt_string("file"),
1129 NXT_CONF_MAP_CSTRZ,
1130 offsetof(nxt_app_lang_module_t, file),
1131 },
1132};
1133
1134
880 name = process->name;
881 stream = process->stream;
882 init = *((nxt_process_init_t *) nxt_process_init(process));
883
884 if (process->state == NXT_PROCESS_STATE_READY) {
885 process->stream = 0;
886 }
887

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

1135 {
1136 nxt_string("file"),
1137 NXT_CONF_MAP_CSTRZ,
1138 offsetof(nxt_app_lang_module_t, file),
1139 },
1140};
1141
1142
1143static nxt_conf_map_t nxt_app_lang_mounts_map[] = {
1144 {
1145 nxt_string("src"),
1146 NXT_CONF_MAP_CSTRZ,
1147 offsetof(nxt_fs_mount_t, src),
1148 },
1149 {
1150 nxt_string("dst"),
1151 NXT_CONF_MAP_CSTRZ,
1152 offsetof(nxt_fs_mount_t, dst),
1153 },
1154 {
1155 nxt_string("fstype"),
1156 NXT_CONF_MAP_CSTRZ,
1157 offsetof(nxt_fs_mount_t, fstype),
1158 },
1159 {
1160 nxt_string("flags"),
1161 NXT_CONF_MAP_INT,
1162 offsetof(nxt_fs_mount_t, flags),
1163 },
1164 {
1165 nxt_string("data"),
1166 NXT_CONF_MAP_CSTRZ,
1167 offsetof(nxt_fs_mount_t, data),
1168 },
1169};
1170
1171
1135static void
1136nxt_main_port_modules_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg)
1137{
1172static void
1173nxt_main_port_modules_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg)
1174{
1138 uint32_t index;
1175 uint32_t index, jindex, nmounts;
1139 nxt_mp_t *mp;
1140 nxt_int_t ret;
1141 nxt_buf_t *b;
1142 nxt_port_t *port;
1143 nxt_runtime_t *rt;
1176 nxt_mp_t *mp;
1177 nxt_int_t ret;
1178 nxt_buf_t *b;
1179 nxt_port_t *port;
1180 nxt_runtime_t *rt;
1144 nxt_conf_value_t *conf, *root, *value;
1181 nxt_fs_mount_t *mnt;
1182 nxt_conf_value_t *conf, *root, *value, *mounts;
1145 nxt_app_lang_module_t *lang;
1146
1147 static nxt_str_t root_path = nxt_string("/");
1183 nxt_app_lang_module_t *lang;
1184
1185 static nxt_str_t root_path = nxt_string("/");
1186 static nxt_str_t mounts_name = nxt_string("mounts");
1148
1149 rt = task->thread->runtime;
1150
1151 if (msg->port_msg.pid != rt->port_by_type[NXT_PROCESS_DISCOVERY]->pid) {
1152 return;
1153 }
1154
1155 if (nxt_exiting) {

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

1196 }
1197
1198 for (index = 0; /* void */ ; index++) {
1199 value = nxt_conf_get_array_element(root, index);
1200 if (value == NULL) {
1201 break;
1202 }
1203
1187
1188 rt = task->thread->runtime;
1189
1190 if (msg->port_msg.pid != rt->port_by_type[NXT_PROCESS_DISCOVERY]->pid) {
1191 return;
1192 }
1193
1194 if (nxt_exiting) {

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

1235 }
1236
1237 for (index = 0; /* void */ ; index++) {
1238 value = nxt_conf_get_array_element(root, index);
1239 if (value == NULL) {
1240 break;
1241 }
1242
1204 lang = nxt_array_add(rt->languages);
1243 lang = nxt_array_zero_add(rt->languages);
1205 if (lang == NULL) {
1206 goto fail;
1207 }
1208
1209 lang->module = NULL;
1210
1211 ret = nxt_conf_map_object(rt->mem_pool, value, nxt_app_lang_module_map,
1212 nxt_nitems(nxt_app_lang_module_map), lang);
1213
1214 if (ret != NXT_OK) {
1215 goto fail;
1216 }
1217
1244 if (lang == NULL) {
1245 goto fail;
1246 }
1247
1248 lang->module = NULL;
1249
1250 ret = nxt_conf_map_object(rt->mem_pool, value, nxt_app_lang_module_map,
1251 nxt_nitems(nxt_app_lang_module_map), lang);
1252
1253 if (ret != NXT_OK) {
1254 goto fail;
1255 }
1256
1218 nxt_debug(task, "lang %d %s \"%s\"",
1219 lang->type, lang->version, lang->file);
1257 mounts = nxt_conf_get_object_member(value, &mounts_name, NULL);
1258 if (mounts == NULL) {
1259 nxt_alert(task, "missing mounts from discovery message.");
1260 goto fail;
1261 }
1262
1263 if (nxt_conf_type(mounts) != NXT_CONF_ARRAY) {
1264 nxt_alert(task, "invalid mounts type from discovery message.");
1265 goto fail;
1266 }
1267
1268 nmounts = nxt_conf_array_elements_count(mounts);
1269
1270 lang->mounts = nxt_array_create(rt->mem_pool, nmounts,
1271 sizeof(nxt_fs_mount_t));
1272
1273 if (lang->mounts == NULL) {
1274 goto fail;
1275 }
1276
1277 for (jindex = 0; /* */; jindex++) {
1278 value = nxt_conf_get_array_element(mounts, jindex);
1279 if (value == NULL) {
1280 break;
1281 }
1282
1283 mnt = nxt_array_zero_add(lang->mounts);
1284 if (mnt == NULL) {
1285 goto fail;
1286 }
1287
1288 ret = nxt_conf_map_object(rt->mem_pool, value,
1289 nxt_app_lang_mounts_map,
1290 nxt_nitems(nxt_app_lang_mounts_map), mnt);
1291
1292 if (ret != NXT_OK) {
1293 goto fail;
1294 }
1295 }
1296
1297 nxt_debug(task, "lang %d %s \"%s\" (%d mounts)",
1298 lang->type, lang->version, lang->file, lang->mounts->nelts);
1220 }
1221
1222 qsort(rt->languages->elts, rt->languages->nelts,
1223 sizeof(nxt_app_lang_module_t), nxt_app_lang_compare);
1224
1225fail:
1226
1227 nxt_mp_destroy(mp);

--- 121 unchanged lines hidden ---
1299 }
1300
1301 qsort(rt->languages->elts, rt->languages->nelts,
1302 sizeof(nxt_app_lang_module_t), nxt_app_lang_compare);
1303
1304fail:
1305
1306 nxt_mp_destroy(mp);

--- 121 unchanged lines hidden ---