Hi,
I noticed a couple of typos (I think) with the DSO code (lib/apr/dso/win32/dso.c) for Win32.
1. FreeLibrary is being called on a struct, not the handle stored within the struct;
2. The symbol's address was being assigned to a struct HINSTANCE, not a FARPROC;
3. The return value 'ressym' was not being dereferenced, so the value was lost after return.
Also, I'm not sure about mod_so.c (for all platforms).
1. ap_dso_sym is being called by passing 'modsym' - but to return a value in the variable
don't we need to pass the address of 'modsym', ie '&modsym'?
2. If we do #1 then should 'modsym' be declared as an ap_dso_handle_sym_t, rather than ap_dso_handle_sym_t
*?
3. 'modp' was not being set to (module *)modsym, so the 'modp->magic != MODULE_MAGIC_COOKIE'
test was always failing. I have rearranged the assignments so that 'modp' refers to the same
location as 'modi->modp'.
Patches are attached inline... they seem to have fixed DSO on Win32.
Hope this helps,
Tim
--- ..\repos\apache\2.0\src\src\lib\apr\dso\win32\dso.c Tue Apr 04 06:41:11 2000
+++ src\lib\apr\dso\win32\dso.c Wed Apr 05 11:42:00 2000
@@ -72,24 +72,24 @@
return APR_SUCCESS;
}
ap_status_t ap_dso_unload(struct ap_dso_handle_t *handle)
{
- if (!FreeLibrary(handle)) {
+ if (!FreeLibrary(handle->handle)) {
return GetLastError();
}
return APR_SUCCESS;
}
ap_status_t ap_dso_sym(ap_dso_handle_sym_t *ressym,
struct ap_dso_handle_t *handle,
const char *symname)
{
- HINSTANCE retval = GetProcAddress(handle->handle, symname);
+ FARPROC retval = GetProcAddress(handle->handle, symname);
if (!retval) {
return GetLastError();
}
- ressym = retval;
+ *ressym = retval;
return APR_SUCCESS;
}
--- ..\repos\apache\2.0\src\src\modules\standard\mod_so.c Tue Apr 04 06:41:12 2000
+++ src\modules\standard\mod_so.c Wed Apr 05 11:31:15 2000
@@ -220,11 +220,11 @@
static const char *load_module(cmd_parms *cmd, void *dummy,
char *modname, char *filename)
{
ap_status_t stat;
ap_dso_handle_t *modhandle;
- ap_dso_handle_sym_t *modsym;
+ ap_dso_handle_sym_t modsym;
module *modp;
const char *szModuleFile=ap_server_root_relative(cmd->pool, filename);
so_server_conf *sconf;
moduleinfo *modi;
moduleinfo *modie;
@@ -261,16 +261,17 @@
/*
* Retrieve the pointer to the module structure through the module name:
* First with the hidden variant (prefix `AP_') and then with the plain
* symbol name.
*/
- if ((stat = ap_dso_sym(modsym, modhandle, modname)) != APR_SUCCESS) {
+ if ((stat = ap_dso_sym(&modsym, modhandle, modname)) != APR_SUCCESS) {
return ap_pstrcat(cmd->pool, "Can't locate API module structure `", modname,
"' in file ", szModuleFile, ": ", ap_os_dso_error(), NULL);
}
- modi->modp = (module *)modsym;
+ modp = (module *)modsym;
modp->dynamic_load_handle = (ap_dso_handle_t *)modhandle;
+ modi->modp = modp;
/*
* Make sure the found module structure is really a module structure
*
*/
|