SPUG: Threads and perl
Brian Aker
brian at tangent.org
Thu Dec 21 14:55:45 CST 2000
So has anyone had much experience with perl and threads?
I have a small server that creates a thread to handle
requests. It would be really nice if I could occasionally
call a perl interpreter to run certain pieces of code. I
have been trying to use the following function:
#include <EXTERN.h>
#include <perl.h>
#include "proto.h"
gchar * perl_handler(gchar *string) {
STRLEN n_a;
PerlInterpreter *my_perl;
gchar *returnable = NULL;
char *embedding[] = { "", "-e", "0" };
my_perl = perl_alloc();
perl_construct(my_perl);
perl_parse(my_perl, NULL, 3, embedding, NULL);
perl_run(my_perl);
eval_pv(string, TRUE);
returnable = SvPV(perl_get_sv("a", FALSE), n_a);
perl_destruct(my_perl);
perl_free(my_perl);
return returnable;
}
I am finding though that if more then one thread
happens to call the perl interpreter at once
I can expect a core dump. So how thread safe is perl
at this point? Anyone know of anything special that
has to be done to make it happy?
Got an idea of a better place to ask this question?
thanks,
-Brian
--
_______________________________________________________
Brian Aker, brian at tangent.org
Slashdot Senior Developer
Seattle, Washington
http://tangent.org/~brian/
http://slashdot.org/
_______________________________________________________
You can't grep a dead tree.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
More information about the spug-list
mailing list