nxt_application.c (584:28e8e1877e62) nxt_application.c (612:217e48a3b091)
1
2/*
3 * Copyright (C) Max Romanov
4 * Copyright (C) Igor Sysoev
5 * Copyright (C) Valentin V. Bartenev
6 * Copyright (C) NGINX, Inc.
7 */
8

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

175}
176
177
178static nxt_int_t
179nxt_discovery_module(nxt_task_t *task, nxt_mp_t *mp, nxt_array_t *modules,
180 const char *name)
181{
182 void *dl;
1
2/*
3 * Copyright (C) Max Romanov
4 * Copyright (C) Igor Sysoev
5 * Copyright (C) Valentin V. Bartenev
6 * Copyright (C) NGINX, Inc.
7 */
8

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

175}
176
177
178static nxt_int_t
179nxt_discovery_module(nxt_task_t *task, nxt_mp_t *mp, nxt_array_t *modules,
180 const char *name)
181{
182 void *dl;
183 nxt_str_t *s;
183 nxt_str_t version;
184 nxt_int_t ret;
185 nxt_uint_t i, n;
186 nxt_module_t *module;
187 nxt_app_type_t type;
188 nxt_application_module_t *app;
189
190 /*
191 * Only memory allocation failure should return NXT_ERROR.

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

198 if (dl == NULL) {
199 nxt_alert(task, "dlopen(\"%s\"), failed: \"%s\"", name, dlerror());
200 return NXT_OK;
201 }
202
203 app = dlsym(dl, "nxt_app_module");
204
205 if (app != NULL) {
184 nxt_int_t ret;
185 nxt_uint_t i, n;
186 nxt_module_t *module;
187 nxt_app_type_t type;
188 nxt_application_module_t *app;
189
190 /*
191 * Only memory allocation failure should return NXT_ERROR.

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

198 if (dl == NULL) {
199 nxt_alert(task, "dlopen(\"%s\"), failed: \"%s\"", name, dlerror());
200 return NXT_OK;
201 }
202
203 app = dlsym(dl, "nxt_app_module");
204
205 if (app != NULL) {
206 nxt_log(task, NXT_LOG_NOTICE, "module: %V %V \"%s\"",
207 &app->type, &app->version, name);
206 nxt_log(task, NXT_LOG_NOTICE, "module: %V %s \"%s\"",
207 &app->type, app->version, name);
208
209 if (app->compat_length != sizeof(compat)
210 || nxt_memcmp(app->compat, compat, sizeof(compat)) != 0)
211 {
212 nxt_log(task, NXT_LOG_NOTICE, "incompatible module %s", name);
213
214 goto done;
215 }

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

220 nxt_log(task, NXT_LOG_NOTICE, "unknown module type %V", &app->type);
221
222 goto done;
223 }
224
225 module = modules->elts;
226 n = modules->nelts;
227
208
209 if (app->compat_length != sizeof(compat)
210 || nxt_memcmp(app->compat, compat, sizeof(compat)) != 0)
211 {
212 nxt_log(task, NXT_LOG_NOTICE, "incompatible module %s", name);
213
214 goto done;
215 }

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

220 nxt_log(task, NXT_LOG_NOTICE, "unknown module type %V", &app->type);
221
222 goto done;
223 }
224
225 module = modules->elts;
226 n = modules->nelts;
227
228 version.start = (u_char *) app->version;
229 version.length = nxt_strlen(app->version);
230
228 for (i = 0; i < n; i++) {
229 if (type == module[i].type
231 for (i = 0; i < n; i++) {
232 if (type == module[i].type
230 && nxt_strstr_eq(&app->version, &module[i].version))
233 && nxt_strstr_eq(&module[i].version, &version))
231 {
232 nxt_log(task, NXT_LOG_NOTICE,
233 "ignoring %s module with the same "
234 "application language version %V %V as in %V",
234 {
235 nxt_log(task, NXT_LOG_NOTICE,
236 "ignoring %s module with the same "
237 "application language version %V %V as in %V",
235 name, &app->type, &app->version,
236 &module[i].file);
238 name, &app->type, version, &module[i].file);
237
238 goto done;
239 }
240 }
241
242 module = nxt_array_add(modules);
243 if (module == NULL) {
244 goto fail;
245 }
246
247 module->type = type;
248
239
240 goto done;
241 }
242 }
243
244 module = nxt_array_add(modules);
245 if (module == NULL) {
246 goto fail;
247 }
248
249 module->type = type;
250
249 s = nxt_str_dup(mp, &module->version, &app->version);
250 if (s == NULL) {
251 nxt_str_dup(mp, &module->version, &version);
252 if (module->version.start == NULL) {
251 goto fail;
252 }
253
254 module->file.length = nxt_strlen(name);
255
256 module->file.start = nxt_mp_alloc(mp, module->file.length);
257 if (module->file.start == NULL) {
258 goto fail;

--- 626 unchanged lines hidden ---
253 goto fail;
254 }
255
256 module->file.length = nxt_strlen(name);
257
258 module->file.start = nxt_mp_alloc(mp, module->file.length);
259 if (module->file.start == NULL) {
260 goto fail;

--- 626 unchanged lines hidden ---