Return-Path: Delivered-To: apmail-apache-cvs-archive@apache.org Received: (qmail 77091 invoked by uid 500); 31 May 2000 02:30:33 -0000 Mailing-List: contact apache-cvs-help@apache.org; run by ezmlm Precedence: bulk X-No-Archive: yes Reply-To: new-httpd@apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list apache-cvs@apache.org Received: (qmail 77075 invoked by uid 500); 31 May 2000 02:30:32 -0000 Delivered-To: apmail-apache-2.0-cvs@apache.org Date: 31 May 2000 02:30:31 -0000 Message-ID: <20000531023031.77071.qmail@locus.apache.org> From: bjh@locus.apache.org To: apache-2.0-cvs@apache.org Subject: cvs commit: apache-2.0/src/modules/standard mod_so.c bjh 00/05/30 19:30:31 Modified: src/lib/apr/dso/os2 dso.c dso.h src/lib/apr/dso/unix dso.c dso.h src/lib/apr/dso/win32 dso.c dso.h src/lib/apr/include apr_dso.h src/lib/apr/misc/unix errorcodes.c src/modules/standard mod_so.c Log: Rework DSO error reporting to be more flexible & informative. This patch covers os/2, unix & win32. Other platforms still need some adjustment (BeOS, AIX). Reviewed by: rbb, gstein Revision Changes Path 1.9 +13 -6 apache-2.0/src/lib/apr/dso/os2/dso.c Index: dso.c =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/dso/os2/dso.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- dso.c 2000/05/29 02:18:41 1.8 +++ dso.c 2000/05/31 02:30:23 1.9 @@ -73,20 +73,22 @@ ap_status_t ap_dso_load(ap_dso_handle_t **res_handle, const char *path, ap_pool_t *ctx) { - char failed_module[1024]; + char failed_module[20]; HMODULE handle; int rc; *res_handle = ap_pcalloc(ctx, sizeof(*res_handle)); + (*res_handle)->cont = ctx; + (*res_handle)->load_error = APR_SUCCESS; + (*res_handle)->failed_module = NULL; if ((rc = DosLoadModule(failed_module, sizeof(failed_module), path, &handle)) != 0) { + (*res_handle)->load_error = APR_OS2_STATUS(rc); (*res_handle)->failed_module = ap_pstrdup(ctx, failed_module); return APR_OS2_STATUS(rc); } (*res_handle)->handle = handle; - (*res_handle)->cont = ctx; - (*res_handle)->failed_module = NULL; ap_register_cleanup(ctx, *res_handle, dso_cleanup, ap_null_cleanup); return APR_SUCCESS; } @@ -129,8 +131,13 @@ -/* Just a stub, it will never be called because we never return APR_EDSOOPEN */ -char *ap_dso_error(char *buf, int bufsize, ap_status_t errcode) +char *ap_dso_error(ap_dso_handle_t *dso, char *buffer, ap_size_t buflen) { - return NULL; + char message[200]; + ap_strerror(dso->load_error, message, sizeof(message)); + strcat(message, " ("); + strcat(message, dso->failed_module); + strcat(message, ")"); + ap_cpystrn(buffer, message, buflen); + return buffer; } 1.9 +1 -0 apache-2.0/src/lib/apr/dso/os2/dso.h Index: dso.h =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/dso/os2/dso.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- dso.h 2000/04/22 06:16:16 1.8 +++ dso.h 2000/05/31 02:30:23 1.9 @@ -66,6 +66,7 @@ struct ap_dso_handle_t { ap_pool_t *cont; /* Context for returning error strings */ HMODULE handle; /* Handle to the DSO loaded */ + ap_status_t load_error; char *failed_module; }; 1.16 +9 -9 apache-2.0/src/lib/apr/dso/unix/dso.c Index: dso.c =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/dso/unix/dso.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- dso.c 2000/05/29 02:18:41 1.15 +++ dso.c 2000/05/31 02:30:24 1.16 @@ -70,16 +70,20 @@ void *os_handle = dlopen(path, RTLD_NOW | RTLD_GLOBAL); #endif - if(os_handle == NULL) + if(os_handle == NULL) { #if defined(HPUX) || defined(HPUX10) || defined(HPUX11) + (*res_handle)->errormsg = strerror(errno); return errno; #else + (*res_handle)->errormsg = dlerror(); return APR_EDSOOPEN; #endif + } *res_handle = ap_pcalloc(ctx, sizeof(*res_handle)); (*res_handle)->handle = (void*)os_handle; (*res_handle)->cont = ctx; + (*res_handle)->errormsg = NULL; return APR_SUCCESS; } @@ -134,13 +138,9 @@ return APR_SUCCESS; } -char *ap_dso_error(char *buf, int bufsize, ap_status_t errcode) +char *ap_dso_error(ap_dso_handle_t *dso, char *buffer, ap_size_t buflen) { -#if defined(HPUX) || defined(HPUX10) || defined(HPUX11) - return strerror(errno); -#elif defined(HAVE_DYLD) - return NULL; -#else - return dlerror(); -#endif + if (dso->errormsg) + return dso->errormsg; + return "No Error"; } 1.8 +1 -0 apache-2.0/src/lib/apr/dso/unix/dso.h Index: dso.h =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/dso/unix/dso.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- dso.h 2000/04/22 06:16:16 1.7 +++ dso.h 2000/05/31 02:30:24 1.8 @@ -85,6 +85,7 @@ struct ap_dso_handle_t { ap_pool_t *cont; void *handle; + char *errormsg; }; #endif 1.6 +7 -4 apache-2.0/src/lib/apr/dso/win32/dso.c Index: dso.c =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/dso/win32/dso.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- dso.c 2000/05/29 02:18:42 1.5 +++ dso.c 2000/05/31 02:30:25 1.6 @@ -62,13 +62,16 @@ ap_pool_t *ctx) { HINSTANCE os_handle = LoadLibraryEx(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); + *res_handle = ap_pcalloc(ctx, sizeof(*res_handle)); + if(os_handle == NULL) { - return GetLastError(); + (*res_handle)->load_error = GetLastError(); + return (*res_handle)->load_error; } - *res_handle = ap_pcalloc(ctx, sizeof(*res_handle)); (*res_handle)->handle = (void*)os_handle; (*res_handle)->cont = ctx; + (*res_handle)->load_error = APR_SUCCESS; return APR_SUCCESS; } @@ -94,7 +97,7 @@ return APR_SUCCESS; } -char *ap_dso_error(char *buf, int bufsize, ap_status_t errcode) +char *ap_dso_error(ap_dso_handle_t *dso, char *buf, ap_size_t bufsize) { - return "An error occured loading a DLL."; + return ap_strerror(dso->load_error, buf, bufsize); } 1.4 +1 -0 apache-2.0/src/lib/apr/dso/win32/dso.h Index: dso.h =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/dso/win32/dso.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- dso.h 2000/04/22 06:16:17 1.3 +++ dso.h 2000/05/31 02:30:25 1.4 @@ -63,6 +63,7 @@ struct ap_dso_handle_t { ap_pool_t *cont; void *handle; + ap_status_t load_error; }; #endif 1.13 +1 -1 apache-2.0/src/lib/apr/include/apr_dso.h Index: apr_dso.h =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/include/apr_dso.h,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- apr_dso.h 2000/05/29 02:18:43 1.12 +++ apr_dso.h 2000/05/31 02:30:26 1.13 @@ -117,7 +117,7 @@ ap_status_t ap_dso_sym(ap_dso_handle_sym_t *ressym, ap_dso_handle_t *handle, const char *symname); -char *ap_dso_error(char *buf, int bufsize, ap_status_t errcode); +char *ap_dso_error(ap_dso_handle_t *dso, char *buf, ap_size_t bufsize); #ifdef __cplusplus } 1.19 +5 -2 apache-2.0/src/lib/apr/misc/unix/errorcodes.c Index: errorcodes.c =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/misc/unix/errorcodes.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- errorcodes.c 2000/05/29 02:18:44 1.18 +++ errorcodes.c 2000/05/31 02:30:27 1.19 @@ -74,7 +74,6 @@ static char *apr_error_string(ap_status_t statcode) { - char buf[256]; switch (statcode) { case APR_ENOPOOL: return "A new pool could not be created."; @@ -103,7 +102,11 @@ case APR_ENOSHMAVAIL: return "No shared memory is currently available"; case APR_EDSOOPEN: - return ap_dso_error(buf, sizeof(buf), APR_EDSOOPEN); +#ifdef HAVE_LIBDL + return dlerror(); +#else + return "DSO load failed"; +#endif case APR_INCHILD: return "Your code just forked, and you are currently executing in the " 1.21 +1 -1 apache-2.0/src/modules/standard/mod_so.c Index: mod_so.c =================================================================== RCS file: /home/cvs/apache-2.0/src/modules/standard/mod_so.c,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- mod_so.c 2000/05/27 22:40:37 1.20 +++ mod_so.c 2000/05/31 02:30:30 1.21 @@ -260,7 +260,7 @@ return ap_pstrcat(cmd->pool, "Cannot load ", szModuleFile, " into server: ", - ap_strerror(status, my_error, sizeof(my_error)), + ap_dso_error(modhandle, my_error, sizeof(my_error)), NULL); } ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, NULL,