[prev in list] [next in list] [prev in thread] [next in thread]
List: apache-modperl
Subject: Re: [mp2]Perl_parse free some resources
From: "Dinesh Premalal" <xydinesh () gmail ! com>
Date: 2008-06-05 20:53:40
Message-ID: e8ff6030806051341k1d40993dtfa4281c346e03567 () mail ! gmail ! com
[Download RAW message or body]
and my functions are.
static axiom_node_t *
wsf_xml_msg_recv_invoke_other (axis2_msg_recv_t* msg_recv,
const axutil_env_t* env,
wsf_svc_info_t* svc_info,
axis2_msg_ctx_t* in_msg_ctx,
axis2_msg_ctx_t* out_msg_ctx,
axis2_char_t* function_name,
axis2_char_t* class_name)
{
AXIS2_PARAM_CHECK (env->error, svc_info, NULL);
AXIS2_PARAM_CHECK (env->error, in_msg_ctx, NULL);
AXIS2_PARAM_CHECK (env->error, out_msg_ctx, NULL);
axiom_node_t *node = NULL;
axiom_node_t *om_node = NULL;
axiom_soap_envelope_t *envelope = NULL;
axiom_soap_body_t *body = NULL;
axis2_char_t *retstr = NULL;
/* extracting payload from the soap message */
envelope = axis2_msg_ctx_get_soap_envelope (in_msg_ctx, env);
body = axiom_soap_envelope_get_body (envelope, env);
om_node = axiom_soap_body_get_base_node (body, env);
om_node = axiom_node_get_first_child (om_node, env);
axis2_char_t *embedding[] = {"", NULL};
if (!svc_info->script_filename)
{
AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI,
"perl function invocation failed, script_file name
not found for \
service %s", svc_info->svc_name);
return NULL;
}
/* passing script real path into perl interpreter. */
embedding[1] = svc_info->script_filename;
my_perl = perl_alloc();
perl_construct( my_perl );
/* loading WSO2::WSF::C and WSO2::WSF::Server using dynamic loader */
eval_pv("use WSO2::WSF::C", FALSE);
eval_pv("use WSO2::WSF::Server", FALSE);
if (perl_parse(my_perl, xs_init, 2, embedding, NULL))
{
AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI, "perl_parse method
failed");
return NULL;
}
perl_run(my_perl);
if (SvTRUE(ERRSV))
{
AXIS2_LOG_DEBUG (env->log, AXIS2_LOG_SI, "invoke perl function
failed");
}
retstr = invoke_perl_function(env, om_node, function_name, NULL);
if (retstr)
{
node = wsf_util_deserialize_buffer (env, retstr);
}
perl_destruct(my_perl);
perl_free(my_perl);
return node;
}
static axis2_char_t *
invoke_perl_function(const axutil_env_t *env, axiom_node_t *om_node,
axis2_char_t *operation, axis2_char_t *class_name)
{
int count = 0;
axis2_char_t *inmsg = NULL;
axis2_char_t *ret = NULL;
if (!operation)
{
AXIS2_LOG_DEBUG (env->log, AXIS2_LOG_SI,
"invoking perl function failed, operation not
available");
return;
}
if (om_node)
{
inmsg = axiom_node_to_string (om_node, env);
}
dSP ;
ENTER ;
SAVETMPS ;
PUSHMARK(SP) ;
XPUSHs(sv_2mortal(newSVpv(inmsg, 0)));
PUTBACK;
/* calling user perl function which returns a scaler value */
count = perl_call_pv(operation, G_SCALAR);
SPAGAIN;
if (count != 1)
{
croak("perl function invocation failed") ;
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
"perl function %s invocation failed", operation);
}
/* we pop string from the stack and doing strdup on it */
ret = savepv(POPpx);
PUTBACK;
FREETMPS ;
LEAVE ;
return ret;
}
/* xs_init is for support dynamic loading of modules */
static void
xs_init(pTHX)
{
char *file = __FILE__;
dXSUB_SYS;
/* DynaLoader is a special case */
newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
}
thanks,
Dinesh
--
http://nethu.org/
[Attachment #3 (text/html)]
and my functions are.<br><br>static axiom_node_t *<br>wsf_xml_msg_recv_invoke_other \
(axis2_msg_recv_t* msg_recv,<br> \
\
const axutil_env_t* env,<br> \
&n \
bsp; \
wsf_svc_info_t* svc_info,<br> &nb \
sp; \
axis2_msg_ctx_t* in_msg_ctx,<br> \
\
axis2_msg_ctx_t* out_msg_ctx,<br>   \
; \
axis2_char_t* function_name,<br>
&n \
bsp; \
axis2_char_t* class_name)<br>{<br> AXIS2_PARAM_CHECK \
(env->error, svc_info, NULL);<br> AXIS2_PARAM_CHECK \
(env->error, in_msg_ctx, NULL);<br> AXIS2_PARAM_CHECK \
(env->error, out_msg_ctx, NULL);<br>
<br> axiom_node_t *node = NULL;<br> axiom_node_t \
*om_node = NULL;<br> axiom_soap_envelope_t *envelope = \
NULL;<br> axiom_soap_body_t *body = NULL;<br> \
axis2_char_t *retstr = NULL;<br><br> /* extracting payload from the \
soap message */<br>
envelope = axis2_msg_ctx_get_soap_envelope (in_msg_ctx, \
env);<br> body = axiom_soap_envelope_get_body (envelope, \
env);<br> om_node = axiom_soap_body_get_base_node (body, \
env);<br> om_node = axiom_node_get_first_child (om_node, env);<br>
<br> axis2_char_t *embedding[] = {"", \
NULL};<br> if (!svc_info->script_filename)<br> \
{<br> AXIS2_LOG_ERROR (env->log, \
AXIS2_LOG_SI, <br> \
"perl function invocation failed, script_file name not found for \<br>
service %s", svc_info->svc_name);<br> \
return NULL;<br> }<br> /* passing script real \
path into perl interpreter. */<br> embedding[1] = \
svc_info->script_filename;<br><br> my_perl = perl_alloc();<br>
perl_construct( my_perl );<br> /* loading \
WSO2::WSF::C and WSO2::WSF::Server using dynamic loader */<br> \
eval_pv("use WSO2::WSF::C", FALSE);<br> eval_pv("use \
WSO2::WSF::Server", FALSE);<br>
<br> if (perl_parse(my_perl, xs_init, 2, embedding, \
NULL))<br> {<br> \
AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI, "perl_parse method \
failed");<br> return \
NULL;<br> }<br><br> perl_run(my_perl);<br>
<br> if (SvTRUE(ERRSV))<br> \
{<br> AXIS2_LOG_DEBUG (env->log, \
AXIS2_LOG_SI, "invoke perl function failed");<br> \
}<br><br> retstr = invoke_perl_function(env, om_node, \
function_name, NULL);<br>
<br> if (retstr)<br> \
{<br> node = wsf_util_deserialize_buffer \
(env, retstr);<br> }<br><br> \
perl_destruct(my_perl);<br> \
perl_free(my_perl);<br> return node;<br>}<br><br>static \
axis2_char_t *<br>invoke_perl_function(const axutil_env_t *env, axiom_node_t \
*om_node, <br>
\
axis2_char_t *operation, axis2_char_t *class_name)<br>{<br> int \
count = 0;<br> axis2_char_t *inmsg = NULL;<br> \
axis2_char_t *ret = NULL;<br><br> if \
(!operation)<br> {<br> \
AXIS2_LOG_DEBUG (env->log, AXIS2_LOG_SI, <br>
\
"invoking perl function failed, operation not \
available");<br> \
return;<br> }<br><br> if \
(om_node)<br> {<br> inmsg \
= axiom_node_to_string (om_node, env);<br> }<br>
<br> dSP ;<br><br> ENTER ;<br> \
SAVETMPS ;<br><br> PUSHMARK(SP) ;<br> \
XPUSHs(sv_2mortal(newSVpv<div>(inmsg, 0)));<br> \
PUTBACK;<br><br> /* calling user perl function which returns a \
scaler value */<br> count = perl_call_pv(operation, G_SCALAR);<br>
SPAGAIN;<br><br> if (count != \
1)<br> {<br> \
croak("perl function invocation failed") \
;<br> AXIS2_LOG_ERROR(env->log, \
AXIS2_LOG_SI, <br> \
"perl function %s invocation failed", operation);<br>
<br> }<br><br> /* we pop string from the stack \
and doing strdup on it */<br> ret = \
savepv(POPpx);<br><br> PUTBACK;<br> FREETMPS \
;<br> LEAVE ;<br> return ret;<br>}<br><br><br>/* \
xs_init is for support dynamic loading of modules */<br>
static void<br>xs_init(pTHX)<br>{<br> char *file = \
__FILE__;<br> dXSUB_SYS;<br><br> /* DynaLoader is \
a special case */<br> \
newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);<br>}<br></div> \
<br>thanks,<br>Dinesh<br>-- <br><a href="http://nethu.org/">http://nethu.org/</a>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic