perl-modperl-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From do...@locus.apache.org
Subject cvs commit: modperl/src/modules/perl mod_perl.c
Date Thu, 09 Mar 2000 15:46:37 GMT
dougm       00/03/09 07:46:36

  Modified:    .        Changes
               src/modules/perl mod_perl.c
  Log:
  dso fix fix
  
  Revision  Changes    Path
  1.418     +5 -0      modperl/Changes
  
  Index: Changes
  ===================================================================
  RCS file: /home/cvs/modperl/Changes,v
  retrieving revision 1.417
  retrieving revision 1.418
  diff -u -r1.417 -r1.418
  --- Changes	2000/03/07 07:54:30	1.417
  +++ Changes	2000/03/09 15:46:36	1.418
  @@ -10,6 +10,11 @@
   
   =item 1.21_03-dev
   
  +dso fix fix: modules with END blocks calling xs code (e.g. DBI) would
  +core dump because the xs .dso had been unloaded, now dso's are not
  +unloaded until after END blocks are called.
  +Thanks to Daniel Jacobowitz and others for spotting
  +
   =item 1.21_02 - March 6, 2000
   
   fix Makefile.PL if $USE_APXS && $PERL_DEBUG
  
  
  
  1.106     +34 -12    modperl/src/modules/perl/mod_perl.c
  
  Index: mod_perl.c
  ===================================================================
  RCS file: /home/cvs/modperl/src/modules/perl/mod_perl.c,v
  retrieving revision 1.105
  retrieving revision 1.106
  diff -u -r1.105 -r1.106
  --- mod_perl.c	2000/03/07 03:10:48	1.105
  +++ mod_perl.c	2000/03/09 15:46:36	1.106
  @@ -418,19 +418,22 @@
   #define dl_librefs "DynaLoader::dl_librefs"
   #define dl_modules "DynaLoader::dl_modules"
   
  -static void unload_xs_so(void)
  +static array_header *xs_dl_librefs(pool *p)
   {
       I32 i;
       AV *librefs = perl_get_av(dl_librefs, FALSE);
       AV *modules = perl_get_av(dl_modules, FALSE);
  +    array_header *arr;
   
       if (!librefs) {
   	MP_TRACE_g(fprintf(stderr, 
   			   "Could not get @%s for unloading.\n",
   			   dl_librefs));
  -	return;
  +	return NULL;
       }
  -	
  +
  +    arr = ap_make_array(p, AvFILL(librefs)-1, sizeof(void *));
  +
       for (i=0; i<=AvFILL(librefs); i++) {
   	void *handle;
   	SV *handle_sv = *av_fetch(librefs, i, FALSE);
  @@ -444,20 +447,38 @@
   	}
   	handle = (void *)SvIV(handle_sv);
   
  -	MP_TRACE_g(fprintf(stderr, "unload_xs_so: %s (0x%lx)\n",
  +	MP_TRACE_g(fprintf(stderr, "%s dl handle == 0x%lx\n",
   			   SvPVX(module_sv), (unsigned long)handle));
   	if (handle) {
  -#ifdef _AIX
  -	    /* make sure Perl's dlclose is used, instead of Apache's */
  -	    dlclose(handle);
  -#else
  -	    ap_os_dso_unload(handle);
  -#endif
  +	    *(void **)ap_push_array(arr) = handle;
   	}
       }
   
       av_clear(modules);
       av_clear(librefs);
  +
  +    return arr;
  +}
  +
  +static void unload_xs_so(array_header *librefs)
  +{
  +    int i;
  +
  +    if (!librefs) {
  +	return;
  +    }
  +
  +    for (i=0; i < librefs->nelts; i++) {
  +	void *handle = ((void **)librefs->elts)[i];
  +	MP_TRACE_g(fprintf(stderr, "unload_xs_so: 0x%lx\n",
  +			   (unsigned long)handle));
  +#ifdef _AIX
  +	/* make sure Perl's dlclose is used, instead of Apache's */
  +	dlclose(handle);
  +#else
  +	ap_os_dso_unload(handle);
  +#endif
  +    }
   }
   
   #if 0
  @@ -485,8 +506,9 @@
   
   static void mp_dso_unload(void *data) 
   { 
  -    unload_xs_so();
  +    array_header *librefs = xs_dl_librefs((pool *)data);
       perl_shutdown(NULL, NULL);
  +    unload_xs_so(librefs);
   } 
   
   static void mp_server_notstarting(void *data) 
  @@ -798,7 +820,7 @@
       saveINC;
   #if MODULE_MAGIC_NUMBER >= MMN_130
       if(perl_module.dynamic_load_handle) 
  -	register_cleanup(p, NULL, mp_dso_unload, null_cleanup); 
  +	register_cleanup(p, p, mp_dso_unload, null_cleanup); 
   #endif
   }
   
  
  
  

Mime
View raw message