I looked at the apr pool cleanup handlers and how they work and seems to me that calling this function after all pool cleanups handlers are done should be pretty safe. Anyway ill put the diffs in here for further reference, maybe someone can look at it at later date. Also diff for second problem.
a...@alex-desktop:~/Desktop/apr-1.3.8/misc/win32$ diff -u misc.c.old misc.c --- misc.c.old 2009-11-13 11:48:45.000000000 +0200 +++ misc.c 2009-11-13 11:49:15.000000000 +0200 @@ -165,6 +165,22 @@ static HMODULE lateDllHandle[DLL_defined] = { NULL, NULL, NULL, NULL, NULL, NULL }; +apr_status_t apr_free_libs() + { + int i; + + for(i=0;i<DLL_defined;i++) + { + if(lateDllHandle[i] != NULL && !FreeLibrary(lateDllHandle[i])) { + return apr_get_os_error(); + } + lateDllHandle[i] = NULL; + } + + return APR_SUCCESS; + } + + FARPROC apr_load_dll_func(apr_dlltoken_e fnLib, char* fnName, int ordinal) { if (!lateDllHandle[fnLib]) { a...@alex-desktop:~/Desktop/apr-1.3.8/include/arch/win32$ diff -u apr_arch_misc.h.old apr_arch_misc.h --- apr_arch_misc.h.old 2009-11-13 11:59:14.000000000 +0200 +++ apr_arch_misc.h 2009-11-13 12:00:42.000000000 +0200 @@ -183,6 +183,8 @@ FARPROC apr_load_dll_func(apr_dlltoken_e fnLib, char *fnName, int ordinal); +apr_status_t apr_free_libs(); + /* The apr_load_dll_func call WILL return 0 set error to * ERROR_INVALID_FUNCTION if the function cannot be loaded */ a...@alex-desktop:~/Desktop/apr-1.3.8/misc/win32$ diff -u start.c.old start.c --- start.c.old 2009-11-13 12:04:33.000000000 +0200 +++ start.c 2009-11-13 12:05:31.000000000 +0200 @@ -221,6 +221,8 @@ WSACleanup(); TlsFree(tls_apr_thread); + + apr_free_libs(); } ----------------------------------------------------------------------------------- a...@alex-desktop:~/Desktop/apr-1.3.8/misc/win32$ diff -u start.c.old start.c --- start.c.old 2009-11-13 12:04:33.000000000 +0200 +++ start.c 2009-11-13 12:10:30.000000000 +0200 @@ -124,7 +124,7 @@ wstrs = CommandLineToArgvW(sysstr, &wstrc); if (wstrs) { *argc = apr_wastrtoastr(argv, wstrs, wstrc); - GlobalFree(wstrs); + LocalFree(wstrs); } }