Hi Jun,

I have a feeling that your mod_perl may have been compiled differently than your original perl. This is often the source of failures with C-based modules under mod_perl. By some combination of re-compiling mod_perl and/or Inline, you may be able to get this working.

Also, the example in the cookbook wasn't targeting mod_perl 2, it was for mod_perl 1, so maybe that's part of the problem too.

 -Ken


On Feb 23, 2005, at 3:51 AM, Jun Ming wrote:

Thanks for your advice.

I found this function in perldoc Inline::C-Cookbook.

     Problem
         How do I use Inline with mod_perl?
     Solution
             package Factorial;
             use strict;
             use Inline Config =>
                        DIRECTORY => '/usr/local/apache/Inline',
                        ENABLE => 'UNTAINT';
             use Inline 'C';
             Inline->init;
             sub handler {
                 my $r = shift;
                 $r->send_http_header('text/plain');
                 printf "%3d! = %10d\n", $_, factorial($_) for 1..100;
                 return Apache::Constants::OK;
             }
             1;
             __DATA__
             __C__
             double factorial(double x) {
                 if (x < 2)  return 1;
                 return x * factorial(x - 1)
             }
     Discussion
         This is a fully functional mod_perl handler that prints
         out the factorial values for the numbers 1 to 100. Since
         we are using Inline under mod_perl, there are a few
         considerations to , um, consider.
         First, mod_perl handlers are usually run with "-T" taint
         detection.  Therefore, we need to enable the UNTAINT
         option. The next thing to deal with is the fact that
         this handler will most likely be loaded after Perl's
         compile time. Since we are using the DATA section, we
         need to use the special "init()" call. And of course we
         need to specify a DIRECTORY that mod_perl can compile
         into. See the above CGI example for more info.

perl v5.8.5          Last change: 2002-10-21                    9



User Contributed Perl Documentation                 C-COOKBOOK(1)

         Other than that, this is a pretty straightforward
         mod_perl handler, tuned for even more speed!
     See Also
         See Stas Bekman's upcoming O'Reilly book on mod_perl to
         which this example was contributed.
     Credits
     Object Oriented Inline


I have commented that line, but it doesn't work still.

Peter Sinnott <[EMAIL PROTECTED]> wrote:
On Wed, Feb 23, 2005 at 04:22:02PM +0800, Jun Ming wrote:
Hi all,
We are using Inline-0.44 as a perl module in Apache 2.0.52 with mod_perl/1.999.20 in Solaris 2.8. There is some error in Apache's error_log, please see the details as reference.


If we use Inline as Example 1, even without any real C program, Apache server always reports the previous handler "exits signal Segmentation fault" and restarts the whole handler. This error happens every time except for the first time when Apache server restarts. And It doesn't happen either if no more http request to it.

However, just as example 2, if we comment the contents only regarding Inline, everything seems in order - Apache doesn't report any error and the process ID keeps as the previous one.

Any advice for us? Thanks in advance.

Try dropping the call to Inline->init(). I dont recall seeing it called directly before,doesn't seem to cause any problems for me from the cmd line but I have a vague recollections of apache not liking reading from the data section of perl scripts and this is the context the inline man pages refer to init in so it could be part of the problem.

--
We exist to competently provide access to corporate leadership skills in
order to assertively disseminate cutting edge information to stay competitive
in tomorrow's world




---------------------------------
Do You Yahoo!?
150~{MrGz~}MP3~{7h?qKQ#,[EMAIL PROTECTED]
[EMAIL PROTECTED]&SP>!SP#,[EMAIL PROTECTED]<!"Q^M<:M?aM<~}
1G~{>MJG~}1000~{UW#,QE;"5gSJWTVz@)H]#!~}



Reply via email to