Skip to content

Commit 1375284

Browse files
committed
enhance error message handling
1 parent f67ef6c commit 1375284

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/ngx_link_func_module.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -796,14 +796,17 @@ ngx_http_link_func_application_compatibility_check(ngx_conf_t *cf, ngx_http_core
796796
}
797797
}
798798

799+
char *error;
799800
scf->_app = dlopen((char*) scf->_libname.data, RTLD_LAZY | RTLD_NOW);
800801
if ( !scf->_app ) {
801-
ngx_conf_log_error(NGX_LOG_ERR, cf, 0, "%s", "unable to initialized the Application ");
802+
if ((error = dlerror()) != NULL) {
803+
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "unable to initialized the Application %s", error);
804+
} else {
805+
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "%s", "unable to initialized the Application unknown issue");
806+
}
802807
return NGX_ERROR;
803808
}
804809

805-
char *error;
806-
807810
/* * check init function block, this version has to be at least init with empty function * */
808811
ngx_http_link_func_app_cycle_handler func;
809812
*(void**)(&func) = dlsym(scf->_app, (const char*)"ngx_link_func_init_cycle");
@@ -878,15 +881,19 @@ ngx_http_link_func_module_init(ngx_cycle_t *cycle) {
878881
if (scf && scf->_libname.len > 0 ) {
879882
ngx_log_error(NGX_LOG_DEBUG, cycle->log, 0, "Loading application= %V", &scf->_libname);
880883

884+
char *error;
881885
scf->_app = dlopen((char*) scf->_libname.data, RTLD_LAZY | RTLD_NOW);
882886
if ( !scf->_app ) {
883-
ngx_log_error(NGX_LOG_ERR, cycle->log, 0, "%s", "unable to initialized the Application ");
887+
if ((error = dlerror()) != NULL) {
888+
ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, "unable to initialized the Application %s", error);
889+
} else {
890+
ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, "%s", "unable to initialized the Application, unknown issue");
891+
}
884892
return NGX_ERROR;
885893
} else {
886894
ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "Application %V loaded successfully ", &scf->_libname);
887895
}
888896

889-
char *error;
890897
/*** loop and without remove queue***/
891898
ngx_queue_t* q;
892899
for (q = ngx_queue_head(scf->_link_func_locs_queue);

0 commit comments

Comments
 (0)