Randy Kobes wrote:

Would the following be correct?

Good catch, Randy. I've missed it since it wasn't failing for me. You can't use fprintf without perl context, since it redefines it to use PerlIO_printf as you have noticed. So yes, it's better to directly use that function ;)


====================================================
Index: xs/APR/APR/APR.xs
===================================================================
RCS file: /home/cvs/modperl-2.0/xs/APR/APR/APR.xs,v
retrieving revision 1.7
diff -u -r1.7 APR.xs
--- xs/APR/APR/APR.xs   25 Aug 2003 23:28:24 -0000      1.7
+++ xs/APR/APR/APR.xs   5 Nov 2003 06:15:44 -0000
@@ -15,11 +15,13 @@
 #include "apr_hooks.h"
 static void extra_apr_init(void)
 {
+    dTHX;
     if (apr_hook_global_pool == NULL) {
         apr_pool_t *global_pool;
         apr_status_t rv = apr_pool_create(&global_pool, NULL);
         if (rv != APR_SUCCESS) {
-            fprintf(stderr, "Fatal error: unable to create global pool "
+            PerlIO_printf(PerlIO_stderr(),
+            "Fatal error: unable to create global pool "
                     "for use with by the scoreboard");
         }
         /* XXX: mutex locking? */
================================================================

It's correct, it's always a good idea not to call dTHX, because it's expensive. If you can pass aTHX as an argument it's always better. I've committed this version:


--- xs/APR/APR/APR.xs   25 Aug 2003 23:28:24 -0000      1.7
+++ xs/APR/APR/APR.xs   5 Nov 2003 07:23:51 -0000
@@ -13,14 +13,15 @@
 /* XXX: APR_initialize doesn't initialize apr_hook_global_pool, needed for
  * work outside httpd, so do it manually PR22605 */
 #include "apr_hooks.h"
-static void extra_apr_init(void)
+static void extra_apr_init(pTHX)
 {
     if (apr_hook_global_pool == NULL) {
         apr_pool_t *global_pool;
         apr_status_t rv = apr_pool_create(&global_pool, NULL);
         if (rv != APR_SUCCESS) {
-            fprintf(stderr, "Fatal error: unable to create global pool "
-                    "for use with by the scoreboard");
+            PerlIO_printf(PerlIO_stderr(),
+                          "Fatal error: unable to create global pool "
+                          "for use with by the scoreboard");
         }
         /* XXX: mutex locking? */
         apr_hook_global_pool = global_pool;
@@ -37,7 +38,7 @@
 BOOT:
     file = file; /* -Wall */
     APR_initialize();
-    extra_apr_init();
+    extra_apr_init(aTHX);

 void
 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