You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Richard Kandarian <ri...@lanl.gov> on 2002/11/19 20:42:08 UTC

Advice/Help with embedding perl

Please forgive me this off topic post. I figure there are Perl embedding experts reading this list and I could use their help.

Background:

1. I have embedded Perl in a (non open source) third party product using an API provided with the product. I've also written xsubs to the product API. We use this product on both Unix and MSW2K/XP so I want my embeded Perl to be at least that portable. I am currently doing my development on MSW2K though I started on Unix.

2. The application is a user application in contrast to mod_perl which is a server.

3. Users can interact with perl scripts run by the embedded Perl via a callback mechanism provided by the product API.

4. Having USE_ITHREADS and(/or?) PERL_IMPLICIT_SYS defined seems to be a real pain when it comes to memory allocation and IO, i.e you have to jump through lots of hoops to do any until you've created at least one interpreter.

Questions:

1. In my application I don't believe there is any advantage to running multiple interpreters concurrently. My design stops and destroys any previous interpreter and starts a new interpreter per user request to run a script. If I need to maintain Perl data from one script to another I can have a top level script "do" lower level scripts (possibly even as a result of callbacks) or write it to and read it back from files.

Any comments/advice?

2. The Perl fork() function is nice but not essential - there are alternatives. Is there any other reason to define USE_MULTI, USE_ITHREADS, and USE_IMP_SYS in the perl*/win32/Makefile (or the equivalent on Unix systems)?

3. If I don't have USE_MULTI, USE_ITHREADS, or USE_IMP_SYS defined, is there any advantage to defining PERL_NO_GET_CONTEXT? (I currently do not define it.)

4. Is there any advantage to having PERL_CORE defined for my embedded Perl? (I currently do not define it.)

5. After an unpredictable number (more than  one) of successful cycles of starting and stopping interpreters either the start of a new interpreter or the destruction of a running interpreter will fail with a memory access violation (my memory fails me but I think really only the latter has occurred). I assumed that this was because my code was some how corrupting memory (maybe aided and abetted by USE_MULTI, USE_ITHREADS, and USE_IMP_SYS), but now I've noticed certain code and comments in mod_perl_perl_destruct() in mod_perl-1.99_07/src/modules/perl/modperl_perl.c which lead me to believe I've found at least a major part of my problem: perl_free() is broken for WIN32 and Perl's handling of environ is broken. Could someone elaborate on this? Are these problems limited to the way Perl is used in modperl? Are they fixed in Perl 5.8?

Thanks very much.


Richard Kandarian
http://www.lanl.gov/cgi-bin/fonelink.pl/085598
Any opinions stated in this message are mine and not expressed on behalf of any other individual or entity unless explicitly noted otherwise. As for the links linked at the very end, my opinion is that they are interesting.
http://www.cundiyo.com/N8LqSO5kPqTYYg/