--- mod_perl.c.orig	Wed Jan 19 06:11:08 2000
+++ mod_perl.c	Wed Jan 19 06:25:01 2000
@@ -417,6 +417,8 @@
 #if MODULE_MAGIC_NUMBER >= MMN_130
 static void mp_dso_unload(void *data) 
 { 
+#ifdef NO_PERL_DLCLOSE
+
     module *modp;
 
     if(!PERL_DSO_UNLOAD)
@@ -433,6 +435,29 @@
 	    modp->dynamic_load_handle = NULL;
 	}
     }
+#else
+	I32 i;
+	void *handle;
+	AV *librefs;
+	SV *handle_sv;
+	
+	librefs = perl_get_av("DynaLoader::dl_librefs", FALSE);
+	if (!librefs) {
+		MP_TRACE(fprintf(stderr, "Could not get @dl_librefs for unloading.\n"));
+		return;
+	}
+	
+	for(i = 0; i <= AvFILL(librefs); i++) {
+		handle_sv = *av_fetch(librefs, i, FALSE);
+		if(!handle_sv) {
+			MP_TRACE(fprintf(stderr, "Could not fetch $dl_librefs[%d]!\n", i));
+			continue;
+		}
+		handle = (void *)SvIV(handle_sv);
+		ap_os_dso_unload(handle) ;
+	}
+    
+#endif
 } 
 #endif
 
