While debugging the current post_config problem I wanted to know which perl interpreter is currently running, so I've added the following wrapper, that under ithreads perl returns the address of my_perl (aTHX) (.e.g 0x92ac760) and 0 under non-threaded perl (0x0). I tend to want to add it to our API (we already have the function that returns the thread id: APR::OS::current_thread_id();).

1) do we want it?

2) is it a good name? I typed ppid quite a few times instead of piid while writing this patch :( ppid stands for Perl Interpreter ID'. So if you think it should have a different please have a say. e.g. current_perl_id() or current_perl_interpreter_id (but it's not really an id, but just an address)

Index: xs/maps/modperl_functions.map
===================================================================
--- xs/maps/modperl_functions.map       (revision 111545)
+++ xs/maps/modperl_functions.map       (working copy)
@@ -5,6 +5,7 @@

 MODULE=ModPerl::Util
  mpxs_ModPerl__Util_untaint | | ...
+ SV *:DEFINE_piid
  DEFINE_exit | | int:status=0
  char *:DEFINE_current_callback
  DEFINE_unload_package | | const char *:package
Index: xs/ModPerl/Util/ModPerl__Util.h
===================================================================
--- xs/ModPerl/Util/ModPerl__Util.h     (revision 111545)
+++ xs/ModPerl/Util/ModPerl__Util.h     (working copy)
@@ -13,6 +13,12 @@
  * limitations under the License.
  */

+#ifdef USE_ITHREADS
+#define mpxs_ModPerl__Util_piid() newSVpvf("0x%lx", (unsigned long)aTHX)
+#else
+#define mpxs_ModPerl__Util_piid() newSVpvf("0x%lx", 0)
+#endif
+
 static MP_INLINE void mpxs_ModPerl__Util_untaint(pTHX_ I32 items,
                                                  SV **MARK, SV **SP)
 {
Index: t/response/TestModperl/util.pm
===================================================================
--- t/response/TestModperl/util.pm      (revision 0)
+++ t/response/TestModperl/util.pm      (revision 0)
@@ -0,0 +1,27 @@
+package TestModperl::util;
+
+# Modperl::Util tests
+
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test;
+use Apache::TestUtil;
+
+use Apache::RequestIO ();
+use Apache::RequestUtil ();
+
+use Apache::Const -compile => 'OK';
+
+sub handler {
+    my $r = shift;
+
+    plan $r, tests => 1;
+
+    ok t_cmp ModPerl::Util::piid(), qr/0x\d+/, "perl interpreter id";
+
+    Apache::OK;
+}
+
+1;
+__END__

--
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to