perl_parse and multi threading

L

lililevy

Hello,

I would very much appreciate your answers on the following issue.
I have a multi threaded application. Each thread is running a function
that creates a perl interpreter and uses it to parse and then run a
perl function from an arbitrary file.
After running this application for a while I'm having a deadlock and
I can see that 10 threads are in the perl_parse function.
I'm running on WInXP with perl 5.8.3.809.
Are any of you are familiar with such a problem? Do you have an idea
why this can happen?

I've attached my function code and marked the line where the threads
are "stuck":

__declspec(dllexport)
long CFTPerlUserExitInstanceRun(char *FileName,char *FuncName,struct
PerlParmInfo *ParmsVec,unsigned int ParmsVecSize,char* pReason,int
*pCount,int *pUserExitRc)
{
long lRc = 0;
int count = -1;
PerlInterpreter* my_perl = NULL;

char *embedding[] = { "", FileName};

while (true)
{
my_perl = perl_alloc();
if (my_perl == NULL)
{
lRc = -1;
break;
}

EnterCriticalSection(&g_ParserCS);
PERL_SET_CONTEXT(my_perl);
PL_perl_destruct_level = 1;
perl_construct(my_perl);
LeaveCriticalSection(&g_ParserCS);

// *****************************************************
// THREADS ARE STUCK IN PERL_PARSE
// *****************************************************
lRc = perl_parse(my_perl, xs_init, 2, embedding , NULL);

if (lRc != 0)
{
lRc = -2;
break;
}

dSP;
ENTER;
SAVETMPS;

PUSHMARK(SP);


// push parms to stack
char ParmType[MAX_PARM_TYPE_LEN];

for(unsigned int i=0; i<ParmsVecSize; i++)
{
strncpy(ParmType, PERL_WRAP_PACKAGE_NAME,
MAX_PARM_TYPE_LEN-1);
strncat(ParmType, "::", MAX_PARM_TYPE_LEN-3);
strncat(ParmType, ParmsVec.parmtype, MAX_PARM_TYPE_LEN-
strlen(PERL_WRAP_PACKAGE_NAME)-3);

SV *pSVParm = sv_newmortal();
sv_setref_pv( pSVParm, ParmType, ParmsVec.parm );
XPUSHs(pSVParm);
}


PUTBACK;
try
{
count = call_pv(FuncName, G_EVAL|G_SCALAR);
}
catch(...)
{
lRc = -3;
}

SPAGAIN;

// Check the eval first
if (SvTRUE(ERRSV))
{
STRLEN n_a;
strncpy(pReason, SvPV(ERRSV, n_a), MAX_PERL_REASON_LENGTH-1);
//@G1028
lRc = -4;
POPs ;
}
else
{
if (count != 1)
{
*pCount = count;
lRc = -5;
}
else
{
*pUserExitRc = POPi;

}
}

PUTBACK ;
FREETMPS ;
LEAVE ;


break;
}

if (my_perl != NULL)
{
EnterCriticalSection(&g_ParserCS);
PL_perl_destruct_level = 1;
perl_destruct(my_perl);
LeaveCriticalSection(&g_ParserCS);
perl_free(my_perl);
}

return lRc;
}

Thank you very much.
Lily.
 
R

Reinhard Pagitsch

Hello,

Hello,

I would very much appreciate your answers on the following issue.
I have a multi threaded application. Each thread is running a function
that creates a perl interpreter and uses it to parse and then run a
perl function from an arbitrary file.
After running this application for a while I'm having a deadlock and
I can see that 10 threads are in the perl_parse function.
I'm running on WInXP with perl 5.8.3.809.
Are any of you are familiar with such a problem? Do you have an idea
why this can happen?

Try to ask in perl.xs. I think they have more experience regarding this
issues.

regards,
Reinhard
 
A

anno4000

Reinhard Pagitsch said:
Hello,



Try to ask in perl.xs. I think they have more experience regarding this
issues.

What is perl.xs? It's not a Usenet group.

Anno
 
D

Dr.Ruud

(e-mail address removed)-berlin.de schreef:
Reinhard Pagitsch:

What is perl.xs? It's not a Usenet group.

You can find it as such at news://nntp.perl.org/perl.xs
and at several other mail2news-gateways.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top