[NeoStats-Devel] [Commits] r2841 - trunk/src

[email protected] Thu, 29 Sep 2005 16:02:31 +1000
Newsgroups gmane.comp.neostats.devel
Message-ID <[email protected]>
Author: Fish
Date: Thu Sep 29 14:02:25 2005
New Revision: 2841

Modified:
   trunk/src/modules.c
   trunk/src/neostats.pm.h
   trunk/src/perl.c
Log:
more Perl Extension support code. 

Modified: trunk/src/modules.c
==============================================================================
--- trunk/src/modules.c	(original)
+++ trunk/src/modules.c	Thu Sep 29 14:02:25 2005
@@ -554,11 +554,6 @@
 	}
 	mod_ptr = hnode_get( modnode );
 	irc_chanalert( ns_botptr, _( "Unloading module %s" ), modname );
-#ifdef USE_PERL
-	/* unload any extensions first */
-	if ((mod_ptr->pm) && (mod_ptr->pm->type = TYPE_EXTENSION)) 
-		unload_perlextension(mod_ptr);
-#endif /* USE_PERL */
 	
 	if( mod_ptr->info->flags & MODULE_FLAG_AUTH )
 		DelAuthModule( mod_ptr );
@@ -573,6 +568,15 @@
 	del_sockets( mod_ptr );
 	/* Delete any associated event list */
 	FreeEventList( mod_ptr );
+
+#ifdef USE_PERL
+	/* unload any extensions first */
+	if ((mod_ptr->pm) && (mod_ptr->pm->type = TYPE_EXTENSION)) {
+		PerlExtensionFini(mod_ptr);
+		unload_perlextension(mod_ptr);
+	}
+#endif /* USE_PERL */
+
 	/* Remove from the module hash so we dont call events for this module 
 	 * during signoff 
 	 */

Modified: trunk/src/neostats.pm.h
==============================================================================
--- trunk/src/neostats.pm.h	(original)
+++ trunk/src/neostats.pm.h	Thu Sep 29 14:02:25 2005
@@ -608,6 +608,7 @@
 "my $callback = shift;\n"
 "my ($package) = caller;\n"
 "$callback = NeoStats::Embed::fix_callback( $package, $callback );\n"
+"NeoStats::debug(\"Callback is $callback\");\n"
 "return NeoStats::Internal::AddTimer($type, $name, $interval, $callback);\n"
 "}\n"
 "\n"

Modified: trunk/src/perl.c
==============================================================================
--- trunk/src/perl.c	(original)
+++ trunk/src/perl.c	Thu Sep 29 14:02:25 2005
@@ -65,7 +65,7 @@
 /*
   this is used for autoload and shutdown callbacks
 */
-static int
+int
 execute_perl (Module *mod, SV * function, int numargs, ...)
 {
 
@@ -74,6 +74,11 @@
 	va_list args;
 	char *tmpstr[10];
 
+	if (!mod->pm) {
+		nlog(LOG_WARNING, "Tried to execute a perl call when perl isn't loaded!");
+		return NS_FAILURE;
+	}
+
 	dSP;
 	ENTER;
 	SAVETMPS;
@@ -1625,8 +1630,8 @@
 		nlog(LOG_WARNING, "Trying to laod a Perl Extension %s in the core? No No", filename);
 		return NS_FAILURE;
 	}	
-	ircsnprintf(filebuf, BUFSIZE, "modules/%s.ple", filename);
-printf("%s\n",filebuf);
+	ircsnprintf(filebuf, BUFSIZE, "modules/%s%s", filename, MOD_EXTEXT);
+
 	mod = load_perlfiles((const char *)filebuf, mod, init_func);
 	
 	SET_RUN_LEVEL(mod);
@@ -1706,7 +1711,7 @@
 
 void PerlModFini(Module *mod)
 {
-	if( IsModuleSynched( mod ) )
+	if( IsModuleSynched( mod ) && mod->pm->type == TYPE_MODULE )
 	{
 		/* only execute unload if synced */
 		execute_perl (mod, sv_2mortal (newSVpv ("NeoStats::Embed::unload", 0)), 1, mod->pm->filename);
@@ -1715,8 +1720,8 @@
 
 void PerlExtensionFini(Module *mod)
 {
-	if (IsModuleSynched(mod) ) {
-		execute_perl(mod, sv_2mortal (newSVpv ("NeoStats::Embed::unloadextension", 0)), 1, mod->pm->filename);
+	if (IsModuleSynched(mod) && mod->pm->type == TYPE_EXTENSION) {
+		execute_perl(mod, sv_2mortal (newSVpv ("NeoStats::Embed::unload", 0)), 1, mod->pm->filename);
 	}
 }