[NeoStats-Devel] [Commits] r2781 - in trunk: modules/extauth modules/perltest src

[email protected] Wed, 31 Aug 2005 01:03:28 +1000
Newsgroups gmane.comp.neostats.devel
Message-ID <[email protected]>
Author: Fish
Date: Tue Aug 30 23:03:19 2005
New Revision: 2781

Modified:
   trunk/modules/extauth/extauth.c
   trunk/modules/perltest/test.pl
   trunk/src/modules.c
   trunk/src/nsevents.c
   trunk/src/perl.c
Log:
perl mods are currently broken while I fix up module pointer passing to execute_perl

Modified: trunk/modules/extauth/extauth.c
==============================================================================
--- trunk/modules/extauth/extauth.c	(original)
+++ trunk/modules/extauth/extauth.c	Tue Aug 30 23:03:19 2005
@@ -148,6 +148,7 @@
 	AccessEntry *access;
 	
 	SET_SEGV_LOCATION();
+	dlog(DEBUG1, "Current Run Level %s", GET_CUR_MODNAME());
 	if( cmdparams->ac < 3 ) 
 	{
 		return NS_ERR_NEED_MORE_PARAMS;

Modified: trunk/modules/perltest/test.pl
==============================================================================
--- trunk/modules/perltest/test.pl	(original)
+++ trunk/modules/perltest/test.pl	Tue Aug 30 23:03:19 2005
@@ -354,7 +354,7 @@
 		flags => '0',
 	};
 	$cmd->{helptext} = \@helptext;
-	NeoStats::AddCmd($bot, $cmd, 'cmd_cb_test');
+	NeoStats::AddCmd("SecureServ", $cmd, 'cmd_cb_test');
 	NeoStats::debug(NeoStats::DelCmd($bot, $cmd->{cmd}));
 	NeoStats::ChanAlert($bot, "Loaded up and ready to rock and role");
 

Modified: trunk/src/modules.c
==============================================================================
--- trunk/src/modules.c	(original)
+++ trunk/src/modules.c	Tue Aug 30 23:03:19 2005
@@ -142,7 +142,9 @@
 		SetModuleSynched( module_ptr );
 #ifdef USE_PERL
 	} else {
+		SET_RUN_LEVEL( module_ptr );
 		err = perl_sync_module( module_ptr );
+		RESET_RUN_LEVEL();
 	}
 #endif
 	return err;
@@ -544,7 +546,10 @@
 		}
 #if USE_PERL
 	} else {
+		SET_RUN_LEVEL( mod_ptr );
 		PerlModFini( mod_ptr );
+		RESET_RUN_LEVEL();
+		SET_SEGV_LOCATION();
 #endif
 	}
 	/* Delete any bots used by this module. Done after ModFini, so the bot 

Modified: trunk/src/nsevents.c
==============================================================================
--- trunk/src/nsevents.c	(original)
+++ trunk/src/nsevents.c	Tue Aug 30 23:03:19 2005
@@ -164,7 +164,9 @@
 #if USE_PERL
 		else if( IS_PERL_MOD( module_ptr ) )
 		{
+			SET_RUN_LEVEL( module_ptr );
 			perl_event_cb( event, cmdparams, module_ptr );
+			RESET_RUN_LEVEL();
 		}			
 #endif
 		return;
@@ -237,7 +239,8 @@
 	if( !mod_ptr->event_list )
 		mod_ptr->event_list = ns_calloc( sizeof( ModuleEvent * ) * EVENT_COUNT );
 	dlog( DEBUG5, "AddEvent: adding %s to %s", EventStrings[eventptr->event], mod_ptr->info->name );
-	if( !eventptr->handler )
+	/* only standard modules have a handler, perl mods use a custom callback */
+	if(IS_STD_MOD(mod_ptr) && !eventptr->handler )
 	{
 		nlog( LOG_ERROR, "AddEvent: missing handler for %s in module %s", EventStrings[eventptr->event], mod_ptr->info->name );
 		return;

Modified: trunk/src/perl.c
==============================================================================
--- trunk/src/perl.c	(original)
+++ trunk/src/perl.c	Tue Aug 30 23:03:19 2005
@@ -79,8 +79,13 @@
 	SAVETMPS;
 	PUSHMARK (SP);
 
-	PERL_SET_CONTEXT((PMI *)mod->pm->my_perl);
+#if 0
 	SET_RUN_LEVEL(mod);
+	dlog(DEBUG1, "Current Runlevel: %s", GET_CUR_MODNAME());
+#endif
+	dlog(DEBUG1, "Current Runlevel in call: %s: %s", GET_CUR_MODNAME(), mod->info->description);
+		
+	PERL_SET_CONTEXT((PMI *)mod->pm->my_perl);
 
 
 
@@ -110,7 +115,9 @@
 	PUTBACK;
 	FREETMPS;
 	LEAVE;
+#if 0
 	RESET_RUN_LEVEL();
+#endif
 	return ret_value;
 }
 
@@ -1558,6 +1565,7 @@
 	   perl_definition array.
 	 */
 	eval_pv (perl_definitions, TRUE);
+	SET_RUN_LEVEL(mod);
 	if (!execute_perl (mod, sv_2mortal (newSVpv ("NeoStats::Embed::load", 0)),
 								1, (char *)filename)) {
 		/* if we are here, check that pm->mod->info has something, otherwise the script didnt register */
@@ -1575,9 +1583,10 @@
 		return NULL;	
 	}
 	assign_mod_number(mod);
-	SET_RUN_LEVEL(mod);
+
 	DBAOpenDatabase();
 	RESET_RUN_LEVEL();
+
 	insert_module(mod);
 
 
@@ -1600,13 +1609,11 @@
 
 void PerlModFini(Module *mod)
 {
-	SET_RUN_LEVEL(mod);
 	if( IsModuleSynched( mod ) )
 	{
 		/* only execute unload if synced */
 		execute_perl (mod, sv_2mortal (newSVpv ("NeoStats::Embed::unload", 0)), 1, mod->pm->filename);
 	}
-	RESET_RUN_LEVEL();
 }
 
 void unload_perlmod(Module *mod)