Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

own "mod_perl" implemenation

by esskar (Deacon)
on Apr 06, 2004 at 00:11 UTC ( #342792=perlquestion: print w/replies, xml ) Need Help??

esskar has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks.

We have developed an standalone server which supports HTTP, SMTP, POP3 and more. It's build in C and part of our product solution and does everything it has to do. :)
The HTTP part also has an CGI Interface and supports Perl.
Now we want to speed up things and thought about our own "mod_perl" implemenation.
So the question is if there are similar projects like mod_perl already but which do not depend on Apache?

Thanks in advance.

Replies are listed 'Best First'.
Re: own "mod_perl" implemenation
by perrin (Chancellor) on Apr 06, 2004 at 00:13 UTC
    Look at FastCGI, SpeedyCGI, and PPerl.
Re: own "mod_perl" implemenation
by gmpassos (Priest) on Apr 06, 2004 at 04:37 UTC
    I think that what you want is to embed Perl in your server.

    Embed Perl in other C program is not difficult, but mod_perl is much more than just Perl inside apache. mod_perl works directly with Apache, and you can handle and control a lot of behaviors of Apache from Perl.

    But I don't want to discourage you. Soo, first perlembed in your App. Than you need to redirect the output of Perl to the socket of the client, without forget the reverse of that, the input (STDIN). Well, I think that you have done something like that for CGI.

    After do the IO work, you need to overwrite exit() and die(), since you can't let the Perl script to close or dump your server. And the work goes. Soo, you will need to like to hack the Perl internals.

    Also you can do a lot of this changes with pure Perl, since the language let you change the Perl interpreter behavior. Soo, here are some modules that can help you to do the pure Perl changes:

  • Die::Alive
  • Safe::World
  • Also you can talk with the mod_perl folks. They can help you, or give you some light.

    Good luck! ;-P

    Graciliano M. P.
    "Creativity is the expression of the liberty".

      Okay; I finally got time to work on this issue. I looked at Die::Alive and Safe::World but this not quit what i want!
      I wrote a C++ wrapper around the <edit>Perl-</edit> C-API which has a function to overwrite a internal perl funcion which looks like this:
      static const char *CoreGlobal = "CORE::GLOBAL"; bool Interpreter::Overwrite(const char *funcname, const char *newfunc) { if(!gv_stashpv(CoreGlobal, 0)) return false; static size_t len_CoreGlobal = strlen(CoreGlobal); size_t len = strlen(funcname); size_t size = len_CoreGlobal + len + 16; char *fullfuncname = new char[size]; strncpy(fullfuncname, CoreGlobal, size); strncat(fullfuncname, "::", size); strncat(fullfuncname, funcname, size); GV *funcgp = gv_fetchpv(fullfuncname, TRUE, SVt_PVCV); GvCV(funcgp) = perl_get_cv(newfunc, TRUE); GvIMPORTED_CV_on(funcgp); delete [] fullfuncname; return true; }
      now i can do something like the following
      Interpreter perl; perl.Overwrite("exit", "Foo::bar");
      which would substitute perl's exit with the function bar from the Foo package. (Not ensuring that Foo is already loaded!)
      The question is now how to achieve the following:
      Everytime the script calls "exit" (or possible die, or similar) my interpreter won't exit but the script stops running.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://342792]
Approved by cLive ;-)
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2023-04-02 08:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?