summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_application.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2017-08-30 03:18:56 +0300
committerIgor Sysoev <igor@sysoev.ru>2017-08-30 03:18:56 +0300
commit740dc67ec844a2606d6d0ac8bb20658a7c9eea42 (patch)
treec7e3f1a633c4e2d6d570dc823d59355de84d5d8a /src/nxt_application.c
parent55fe80600c2f65646c9fe3b548fe951843c11165 (diff)
downloadunit-740dc67ec844a2606d6d0ac8bb20658a7c9eea42.tar.gz
unit-740dc67ec844a2606d6d0ac8bb20658a7c9eea42.tar.bz2
The discovery process did not quit if no modules were not found.
Diffstat (limited to 'src/nxt_application.c')
-rw-r--r--src/nxt_application.c89
1 files changed, 48 insertions, 41 deletions
diff --git a/src/nxt_application.c b/src/nxt_application.c
index dc23c0d7..d9245688 100644
--- a/src/nxt_application.c
+++ b/src/nxt_application.c
@@ -49,6 +49,9 @@ nxt_discovery_start(nxt_task_t *task, void *data)
rt = task->thread->runtime;
b = nxt_discovery_modules(task, rt->modules);
+ if (nxt_slow_path(b == NULL)) {
+ exit(1);
+ }
main_port = rt->port_by_type[NXT_PROCESS_MAIN];
@@ -97,61 +100,65 @@ nxt_discovery_modules(nxt_task_t *task, const char *path)
ret = glob(path, 0, NULL, &glb);
- if (ret == 0) {
- n = glb.gl_pathc;
+ n = glb.gl_pathc;
- modules = nxt_array_create(mp, n, sizeof(nxt_module_t));
- if (modules == NULL) {
- goto fail;
- }
+ if (ret != 0) {
+ nxt_log(task, NXT_LOG_NOTICE,
+ "no modules matching: \"%s\" found", path);
+ n = 0;
+ }
- for (i = 0; i < n; i++) {
- name = glb.gl_pathv[i];
+ modules = nxt_array_create(mp, n, sizeof(nxt_module_t));
+ if (modules == NULL) {
+ goto fail;
+ }
- ret = nxt_discovery_module(task, mp, modules, name);
- if (ret != NXT_OK) {
- goto fail;
- }
- }
+ for (i = 0; i < n; i++) {
+ name = glb.gl_pathv[i];
- size = sizeof("[]") - 1;
- module = modules->elts;
- n = modules->nelts;
+ ret = nxt_discovery_module(task, mp, modules, name);
+ if (ret != NXT_OK) {
+ goto fail;
+ }
+ }
- for (i = 0; i < n; i++) {
- nxt_debug(task, "module: %V %V %V",
- &module[i].type, &module[i].version, &module[i].file);
+ size = sizeof("[]") - 1;
+ module = modules->elts;
+ n = modules->nelts;
- size += sizeof("{\"type\": \"\",") - 1;
- size += sizeof(" \"version\": \"\",") - 1;
- size += sizeof(" \"file\": \"\"},") - 1;
+ for (i = 0; i < n; i++) {
+ nxt_debug(task, "module: %V %V %V",
+ &module[i].type, &module[i].version, &module[i].file);
- size += module[i].type.length
- + module[i].version.length
- + module[i].file.length;
- }
+ size += sizeof("{\"type\": \"\",") - 1;
+ size += sizeof(" \"version\": \"\",") - 1;
+ size += sizeof(" \"file\": \"\"},") - 1;
- b = nxt_buf_mem_alloc(mp, size, 0);
- if (b == NULL) {
- goto fail;
- }
+ size += module[i].type.length
+ + module[i].version.length
+ + module[i].file.length;
+ }
- b->completion_handler = nxt_discovery_completion_handler;
+ b = nxt_buf_mem_alloc(mp, size, 0);
+ if (b == NULL) {
+ goto fail;
+ }
- p = b->mem.free;
- end = b->mem.end;
- *p++ = '[';
+ b->completion_handler = nxt_discovery_completion_handler;
- for (i = 0; i < n; i++) {
- p = nxt_sprintf(p, end,
- "{\"type\": \"%V\", \"version\": \"%V\", \"file\": \"%V\"},",
- &module[i].type, &module[i].version, &module[i].file);
- }
+ p = b->mem.free;
+ end = b->mem.end;
+ *p++ = '[';
- *p++ = ']';
- b->mem.free = p;
+ for (i = 0; i < n; i++) {
+ p = nxt_sprintf(p, end,
+ "{\"type\": \"%V\", \"version\": \"%V\", \"file\": \"%V\"},",
+ &module[i].type, &module[i].version, &module[i].file);
}
+ *p++ = ']';
+ b->mem.free = p;
+
fail:
globfree(&glb);