summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorValentin Bartenev <vbart@nginx.com>2021-11-02 17:34:23 +0300
committerValentin Bartenev <vbart@nginx.com>2021-11-02 17:34:23 +0300
commitb6f4b3afb1eb7d6742beb8968c902e4709c3ced7 (patch)
treef2e9624c6d61ff7ee4fccd031b7d2645b9c8e2ee
parentbd9da8bc8cedb152a15977c85339ae0a4226f0c4 (diff)
downloadunit-b6f4b3afb1eb7d6742beb8968c902e4709c3ced7.tar.gz
unit-b6f4b3afb1eb7d6742beb8968c902e4709c3ced7.tar.bz2
Improved logging of app module load errors.
Diffstat (limited to '')
-rw-r--r--src/nxt_application.c27
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;
}