Re: Scripts works under CGI but not under mod_perl

2007-08-13 Thread Manoj Bist
Hi Perrin,

Is there some recommended way to detect if STDOUT is being manipulated?
This is what I am doing.

1. Build a standalone binary that uses this lib.
2. Run this binary in the debugger and insert breakpoints in read, write,
open and close.

The library is using TCP sockets to communicate with the server.

Is  there some way to debug apache/mod_perl in the debugger?

Thanks a lot,

Manoj.


On 8/13/07, Perrin Harkins <[EMAIL PROTECTED]> wrote:
>
> On 8/13/07, Manoj Bist <[EMAIL PROTECTED]> wrote:
> > Thanks for the response. The C library is a third party library which
> does
> > the following:
> >
> > - Connect to a server running on port 7000 on the local machine.
> > - Make an initialize call
> > <==This call is consistently
> > failing under mod_perl.
>
> Okay, so that's what you need to focus on.  Do you know if it's
> connecting over TCP sockets or pipes?  There may be issues if it's
> trying to manipulate STDOUT.
>
> > The startup.pl that we are using has only 5 lines.
>
> I don't see how this could cause you trouble, unless you are loading
> other things directly from httpd.conf.  It probably has to do with
> STDOUT.
>
> - Perrin
>


Re: Correct way to upload a file

2007-08-13 Thread Fred Moyer

[please cc the mod_perl list when responding]

Mag Gam wrote:
> Fred:
>
> Thanks. Looks like I may look into Mason for its simplification. I 
don't think I have a the patience or enthusiasm to learn the REquestReq 
feature of Mp2.


It's not that hard, I would say it's no more complex than Mason (but 
there are varying schools of thought on that subject which I will not go 
into here).  Here is a hello world handler to give you an example of how 
to get started.


conf/httpd.conf
--

  SetHandler perl-script # tells apache mod_perl handles the request
  PerlResponseHandler My::Hello  # My::Hello::handler handles / requests


lib/My/Hello.pm

package My::Hello;

use strict;
use warnings;

use Apache2::RequestRec ();  # for $r->content_type
use Apache2::RequestIO  ();  # for $r->print
use Apache2::Const -compile => qw( OK );  # for Apache2::Const::OK

sub handler {
   my $r = shift;  # <== here is where you get $r

   $r->content_type('text/plain');  # set the content type to text/plain
   $r->print("Hello world!");   # print the response to the client

   return Apache2::Const::OK;  # return 200 OK
}

HTH

> On 8/11/07, *Fred Moyer* <[EMAIL PROTECTED] 
> wrote:

>
>  > I noticed I have to use Apache::Request and Apache::Cookie.
>  > In, http://perl.apache.org/docs/2.0/api/Apache2/RequestRec.html,
> there is
>  > a
>  > $r which is request object. How do I create that? Is there an 
example

>  > anywhere I can follow?
>
> It sounds like you haven't created a mod_perl handler before, 
this page

> should answer your questions.
>
> http://perl.apache.org/docs/2.0/user/intro/start_fast.html
>
>  > On 8/10/07, Jonathan Vanasco <[EMAIL PROTECTED]
> > wrote:
>  >>
>  >>
>  >> On Aug 10, 2007, at 10:25 PM, Mag Gam wrote:
>  >>
>  >> > I have just started learning perl and mod_perl, and I must 
admit I

>  >> > am enjoying it a lot!
>  >> > I am tying to upload a file, so I can do some calculations 
to the

>  >> > file, my question is what is the "correct" and most
> "efficient" way
>  >> > to upload the file, and perform the calculations? Should I
> consider
>  >> > using the CGI module?
>  >>
>  >> libapreq
>  >> http://httpd.apache.org/apreq/
>  >>
>  >> CGI is a close second
>  >>
>  >
>
>
>





Re: Scripts works under CGI but not under mod_perl

2007-08-13 Thread Perrin Harkins
On 8/13/07, Manoj Bist <[EMAIL PROTECTED]> wrote:
> Thanks for the response. The C library is a third party library which does
> the following:
>
> - Connect to a server running on port 7000 on the local machine.
> - Make an initialize call
> <==This call is consistently
> failing under mod_perl.

Okay, so that's what you need to focus on.  Do you know if it's
connecting over TCP sockets or pipes?  There may be issues if it's
trying to manipulate STDOUT.

> The startup.pl that we are using has only 5 lines.

I don't see how this could cause you trouble, unless you are loading
other things directly from httpd.conf.  It probably has to do with
STDOUT.

- Perrin


Re: Scripts works under CGI but not under mod_perl

2007-08-13 Thread Manoj Bist
 Hi Perrin,

Thanks for the response. The C library is a third party library which does
the following:

- Connect to a server running on port 7000 on the local machine.
- Make an initialize call <==This call is
consistently failing under mod_perl.
- Grab binary data returned by the server.

What is most baffling is that the same perl code works fine when run as a
standalone application or as CGI but consistently fails under mod_perl. The
parameters passed to these call are the following:

- a struct which contains a couple of  "character strings"
- pointer to a handle that would be filled up after the call.

I have tried running a standalone perl application that uses the perl
binding under valgrind. However it did not expose memory issues.

The startup.pl that we are using has only 5 lines. I have included it here.

 11 use ModPerl::Registry;
 12 use Apache2::Const;
 13 use CGI qw(-compile :all);
 14 use CGI::Carp ();
 15 1;

- Manoj.


On 8/13/07, Perrin Harkins <[EMAIL PROTECTED]> wrote:
>
> On 8/13/07, Manoj Bist <[EMAIL PROTECTED]> wrote:
> > I created a perl binding for a third party "C "library using swig. This
> > works fine under CGI but consistently fails under mod_perl.
> > Is there a known set of calls(mulithreading etc.) that is not expected
> to
> > work under mod_perl?
>
> Modules with C code normally work fine with mod_perl.  The only
> generic problems I can think of are ones where you open sockets or
> files in startup.pl and then fork and try to share them.
>
> Can you tell us more about what the C library does and how it fails?
>
> - Perrin
>


Re: Scripts works under CGI but not under mod_perl

2007-08-13 Thread Perrin Harkins
On 8/13/07, Manoj Bist <[EMAIL PROTECTED]> wrote:
> I created a perl binding for a third party "C "library using swig. This
> works fine under CGI but consistently fails under mod_perl.
> Is there a known set of calls(mulithreading etc.) that is not expected to
> work under mod_perl?

Modules with C code normally work fine with mod_perl.  The only
generic problems I can think of are ones where you open sockets or
files in startup.pl and then fork and try to share them.

Can you tell us more about what the C library does and how it fails?

- Perrin


Re: SV: [mp2+Win32] Frustration over Apache 2.0/ 2.2 restart failure

2007-08-13 Thread Randy Kobes

On Sun, 12 Aug 2007, Foo JH wrote:


William, the point I was trying to make is:

1. My restart test scope merely loads modperl + libapreq. There is ZERO 
application code loaded. In other words, all I did after installing modperl + 
libapreq is to ONLY load them into httpd.conf:

LoadFile c:/Perl/bin/perl58.dll
LoadModule perl_module modules/mod_perl.so

LoadFile bin/libapreq2.dll
LoadModule apreq_module modules/mod_apreq2.so

Noticed there is no other code loaded. No database used. Super duper minimal 
test model.


I can confirm the above happens, and without libapreq2.
My platform is
  Apache/2.2.4 (Win32)
  mod_perl/2.0.4-dev
  Perl/v5.8.8
  Win XP
Just loading mod_perl through
  LoadModule perl_module modules/mod_perl.so
without any other perl modules loading results, upon a
restart,

  [Mon Aug 13 06:26:27 2007] [notice] Apache/2.2.4 (Win32) 
mod_perl/2.0.4-dev Perl/v5.8.8 configured -- resuming normal 
operations
[Mon Aug 13 06:26:27 2007] [notice] Server built: Jan  9 
2007 23:17:20
[Mon Aug 13 06:26:27 2007] [notice] Parent: Created child 
process 1888
[Mon Aug 13 06:26:27 2007] [notice] Child 1888: Child 
process is running
[Mon Aug 13 06:26:27 2007] [notice] Child 1888: Acquired the 
start mutex.
[Mon Aug 13 06:26:27 2007] [notice] Child 1888: Starting 250 
worker threads.
[Mon Aug 13 06:26:27 2007] [notice] Child 1888: Starting 
thread to listen on port 80.
[Mon Aug 13 06:26:42 2007] [notice] Parent: Received restart 
signal -- Restarting the server.
[Mon Aug 13 06:26:42 2007] [notice] Child 1888: Exit event 
signaled. Child process is ending.
[Mon Aug 13 06:26:42 2007] [notice] Apache/2.2.4 (Win32) 
mod_perl/2.0.4-dev Perl/v5.8.8 configured -- resuming normal 
operations
[Mon Aug 13 06:26:42 2007] [notice] Server built: Jan  9 
2007 23:17:20
[Mon Aug 13 06:26:42 2007] [crit] (70008)Partial results are 
valid but processing is incomplete: Parent: Failed to create 
the child process.
[Mon Aug 13 06:26:42 2007] [crit] (OS 6)The handle is 
invalid.  : master_main: create child process failed. 
Exiting.
[Mon Aug 13 06:26:43 2007] [notice] Child 1888: Released the 
start mutex
[Mon Aug 13 06:26:44 2007] [notice] Child 1888: Waiting for 
250 worker threads to exit.
[Mon Aug 13 06:26:44 2007] [notice] Child 1888: All worker 
threads have exited.
[Mon Aug 13 06:26:44 2007] [notice] Child 1888: Child 
process is exiting
[Mon Aug 13 06:27:12 2007] [notice] Parent: Forcing 
termination of child process 36


A stop/start works fine, as does a restart without
loading mod_perl. As Foo noted in a later message,
the win32 binaries from
  http://www.apachelounge.com/download/
don't seem to suffer this problem. However, this is built
with VC++ 2005 (VC 8), and as such, there may be problems
running it with ActivePerl and/or perl modules compiled
for ActivePerl (eg, installed through ppm), which
use VC++ 6 to build.

--
best regards,
Randy Kobes


Frustration over Apache 2.0/ 2.2 restart failure => possible package found

2007-08-13 Thread Foo JH

Hello Henrik, all,

With kind references from the modperl community, I've managed to confirm 
a working Win32 modperl stack that will survive an apache restart based 
on zero application code config. Not only does this stack do exactly 
that, it is based on a more recent Visual C++ compiler, and claims 
improved performance over the reference binary from Apache.


Please check out the binaries from:
http://www.apachelounge.com/download/

To summarise the procedures:
1. Install Apache 2.2 binaries from ApacheLounge
2. Install ActivePerl (I tested on build 822)
3. Install modperl via ppd from ApacheLounge
4. Install libapreq2 from http://theoryx5.uwinnipeg.ca/ppms/
5. Insert the following into httpd.conf
ServerSignature on
LoadModule perl_module modules/mod_perl.so
LoadFile "C:/Apache2/bin/libapreq2.dll"
LoadModule apreq_module modules/mod_apreq2.so

My test OS is Windows 2003.

Henrik, I hope this is good news for you.

Thanks guys.

Henrik Schak Hansen wrote:

Hi Foo

I finally gave up on Apahce/modperl2 on win32 in various version
combinations. I kept hoping that newer versions of apache/modperl would
stabilize it but rather it seemed to get worse. Daily apache/modperl
would fail and modperl would restart maybe 10 time within a few minutes
before finally working again. Only because I have a load balancer in
front of several web servers have I been able to keep going.
Anyway, now I have moved to Linux a week ago, and so fare I haven't
experienced any problems (except having to tweak different parameters).
So I cross my fingers and hope it will stay this way.

Not much of help for you I know, but I remember we have talked about
this before

Regards
Henrik Schak Hansen




-Oprindelig meddelelse-
Fra: Foo JH [mailto:[EMAIL PROTECTED] 
Sendt: 10. august 2007 10:10

Til: modperl@perl.apache.org
Emne: [mp2+Win32] Frustration over Apache 2.0/ 2.2 restart failure

Hi all,

I am rather disappointed (and a little frustrated as well) on modperl's
inability to survive an Apache restart on the Windows platform. The
platform combo tested are Windows 2003 + Apache 2.2 (and Apache 2.0) +
modperl2 + libapreq2

I have come to accept the fact that once in a while modperl on Win32
will segfault, but the old Apache I tried (year 2005 iirc) seems to
recover, though it threw a windows fault dialog that scared the wits out
of my clients. But this time it's just unacceptable. The odd thing is,
if you try to start apache after it failed, it will fail again. You have
to wait about a minute (or more) before starting the server.

I don't mind any creative workarounds. Please share with me any
suggestions or tips that can circumvent this. Thanks much.


---
[Denne E-mail blev scannet for virus af Declude Virus]
[This E-mail was scanned for viruses by Declude Virus]