diff options
author | Valentin Bartenev <vbart@nginx.com> | 2021-11-02 17:34:23 +0300 |
---|---|---|
committer | Valentin Bartenev <vbart@nginx.com> | 2021-11-02 17:34:23 +0300 |
commit | b6f4b3afb1eb7d6742beb8968c902e4709c3ced7 (patch) | |
tree | f2e9624c6d61ff7ee4fccd031b7d2645b9c8e2ee /src | |
parent | bd9da8bc8cedb152a15977c85339ae0a4226f0c4 (diff) | |
download | unit-b6f4b3afb1eb7d6742beb8968c902e4709c3ced7.tar.gz unit-b6f4b3afb1eb7d6742beb8968c902e4709c3ced7.tar.bz2 |
Improved logging of app module load errors.
Diffstat (limited to 'src')
-rw-r--r-- | src/nxt_application.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/src/nxt_application.c b/src/nxt_application.c index 096ba4b4..f42905eb 100644 --- a/src/nxt_application.c +++ b/src/nxt_application.c @@ -527,17 +527,34 @@ nxt_app_setup(nxt_task_t *task, nxt_process_t *process) static nxt_app_module_t * nxt_app_module_load(nxt_task_t *task, const char *name) { - void *dl; + char *err; + void *dl; + nxt_app_module_t *app; dl = dlopen(name, RTLD_GLOBAL | RTLD_LAZY); - if (dl != NULL) { - return dlsym(dl, "nxt_app_module"); + if (nxt_slow_path(dl == NULL)) { + err = dlerror(); + nxt_alert(task, "dlopen(\"%s\") failed: \"%s\"", + name, err != NULL ? err : "(null)"); + return NULL; } - nxt_alert(task, "dlopen(\"%s\"), failed: \"%s\"", name, dlerror()); + app = dlsym(dl, "nxt_app_module"); + + if (nxt_slow_path(app == NULL)) { + err = dlerror(); + nxt_alert(task, "dlsym(\"%s\", \"nxt_app_module\") failed: \"%s\"", + name, err != NULL ? err : "(null)"); - return NULL; + if (dlclose(dl) != 0) { + err = dlerror(); + nxt_alert(task, "dlclose(\"%s\") failed: \"%s\"", + name, err != NULL ? err : "(null)"); + } + } + + return app; } |