__Unofficial__ patch for embedded Perl Interpeter support in Nagios 1.1 (fixes SEGV on start-up with threaded typically Linux Perls).

Wolfgang Rosenauer stark at suse.de
Tue Jun 24 11:42:21 CEST 2003


Hi,

On Sat, 21 Jun 2003, Stanley Hopcroft wrote:

> The patch, while not extensively tested, _should_ fix the SEGV on
> starting up (for any args, -h -m or -v) of a Nagios 1.1 configured
> with an embedded Perl interpreter (for greater efficiency in executing
> Perl plugins).
>
> Credits
>
> 	Ethan Galstad
> 	Reuben Farrelly
>
> 	I believe the patch was originally the work of Mr Reuben
> Farrelly from Suse (the Suse 8 Nag 'package' has this problem fixed).

the first incarnation of this patch could be found here:
http://sourceforge.net/mailarchive/forum.php?thread_id=1203839&forum_id=1872
and the current patch for Nagios 1.1 is attached.

I got this patch from my colleague Michael Schroeder.
There is no Reuben Farrely working for SuSE ;-)

PS: And as always you can find current packages of Nagios for SuSE here:
 ftp://ftp.suse.com/pub/people/stark/nagios/


CU,

   Wolfgang (stark at suse.de)

-- 
SuSE Linux AG,          Tel:   +49-(0)180-5003612
Deutschherrnstr. 15-19  Fax:   +49-(0)911-740 53 489
90429 Nuernberg,        Email: stark at suse.de
Germany                 WWW:   http://www.suse.de/
-------------- next part --------------
--- base/nagios.c
+++ base/nagios.c
@@ -58,6 +58,8 @@
 #include <perl.h>
 static PerlInterpreter *my_perl;
 #include <fcntl.h>
+#undef ctime	/* don't need perl's threaded version */
+#undef printf   /* can't use perl's printf until initialized */
 
 /* include PERL xs_init code for module and C library support */
 
@@ -86,17 +88,14 @@
 #  endif
 #endif
  
-EXTERN_C void xs_init _((void));
+EXTERN_C void xs_init _((pTHX));
 
-EXTERN_C void boot_DynaLoader _((CV* cv));
+EXTERN_C void boot_DynaLoader _((pTHX_ CV* cv));
 
 EXTERN_C void
-xs_init(void)
+xs_init(pTHX)
 {
 	char *file = __FILE__;
-#ifdef THREADEDPERL
-	dTHX;
-#endif
 	dXSUB_SYS;
 
 	/* DynaLoader is a special case */
@@ -779,9 +778,12 @@
 
 		/* cleanup embedded perl */
 #ifdef EMBEDDEDPERL
-		PL_perl_destruct_level=0;
-		perl_destruct(perl);
-		perl_free(perl);
+		{
+		    dTHX;
+		    PL_perl_destruct_level=0;
+		    perl_destruct(perl);
+		    perl_free(perl);
+		}
 #endif
 
 		/* log a shutdown message */
--- base/utils.c
+++ base/utils.c
@@ -49,6 +49,11 @@
 #include <fcntl.h>
 /* In perl.h (or friends) there is a macro that defines sighandler as Perl_sighandler, so we must #undef it so we can use our sighandler() function */
 #undef sighandler
+/* and we don't need perl's reentrant versions */
+#undef localtime
+#undef getpwnam
+#undef getgrnam
+#undef strerror
 #endif
 
 char            *my_strtok_buffer=NULL;
--- contrib/mini_epn.c
+++ contrib/mini_epn.c
@@ -112,9 +112,10 @@
                         printf("embedded perl plugin return code: %d. plugin output: %s\n",pclose_result, plugin_output);
 		}
 	}
-        
-        PL_perl_destruct_level = 0;
-        perl_destruct(perl);
-        perl_free(perl);
-        exit(exitstatus);
+               {
+                   dTHX;
+                   PL_perl_destruct_level=0;
+                   perl_destruct(perl);
+                   perl_free(perl);
+               }
 }


More information about the Users mailing list