You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-user@axis.apache.org by "Lefrancois, Carl" <Ca...@axa-canada.com> on 2008/10/27 15:14:40 UTC

RE : early env cleanup in asynchronous mode

Thanks for your reply, Supun

I am hesitant to raise a Jira right away for two reasons: my version of Axis2/C is a few months old and I believe this behaviour may be right, and it is me who is calling the wrong function.  Are we sure there is a bug here?

Has anyone on the list made a client which uses the same env for many web service calls in asynchronous mode?  Maybe in this mode we need to create a new env for each call?

If I cannot find a better function and no one replies saying this should work, then a Jira could be a good idea.  I think this functionality is something Axis2/C should support.


-Carl


-----Message d'origine-----
De : Supun Kamburugamuva [mailto:supun06@gmail.com] 
Envoyé : samedi, octobre 25, 2008 00:37
À : Apache AXIS C User List
Objet : Re: early env cleanup in asynchronous mode


Recently I got this error. But not sure what is happening exactly. Need to have a thorough look. Please create a Jira.

Supun.


On Sat, Oct 25, 2008 at 12:27 AM, Lefrancois, Carl <Ca...@axa-canada.com> wrote:

Hello all,

No doubt my problem is due to user error, but I'm not sure what to try
next to fix this problem.

I am working to implement asynchronous mode client calls in a project
which is already fairly mature and works well in blocking mode.  When my
DLL is loaded, I initialise the Axis2/C environment, and I free the
environment on unload of the DLL.  In between I can make many web
service calls in blocking mode.

What is happening now is that I used code from the echo_non_blocking.c
sample to implement asynchronous mode but I get an access violation
because the env is freed inside the function which calls my on_complete
callback.  After this function is completed my application still tries
to use the same env.

Can someone point out which function to call so I can make use of the
asynchronous callbacks and still keep the same environment between
calls?




here is the code I am using:
========================================================================
=============================
     /* Send request */
     svc_client = axis2_stub_get_svc_client (stub, axis2_env );
     AXIS2_LOG_INFO(axis2_env->log, "\n---appel d'axis2 send receive
INITIÉ---\n");  ******* I see this in the log
     axis2_svc_client_send_receive_non_blocking(svc_client, axis2_env,
payload, callback);
     AXIS2_LOG_INFO(axis2_env->log, "\n---appel d'axis2 send receive
RETOURNÉ---\n");******* I see this in the log

     /** Wait till callback is complete. Simply keep the parent thread
running
        until our on_complete or on_error is invoked */
     while (count < 15)
     {
         if (isComplete)
         {
             /* We are done with the callback */
             break;
         }
         AXIS2_LOG_INFO(axis2_env->log, "\n---AXIS DORT---\n");
******* I see this in the log
         AXIS2_SLEEP(1);
         AXIS2_LOG_INFO(axis2_env->log, "\n---AXIS SE RÉVEILLE---\n");
******* crash happens here after on_complete.. Axis2_env is freed!
         count++;
     }

     if (!(count < 15))
     {
       AXIS2_LOG_INFO(axis2_env->log, "\n---appel d'axis2 send receive
COMPLÉTÉ TIMEOUT---\n");   **** never see this in log
       *lpiEtatTraitement = ETAT_TRAITEMENT_TIMEOUT;
     }
     else
     {
       AXIS2_LOG_INFO(axis2_env->log, "\n---appel d'axis2 send receive
COMPLÉTÉ OK---\n");        **** never see this in log
     }
========================================================================
=============================


axis2_status_t AXIS2_CALL OnRatingStubOpComplete(     struct
axis2_callback * callback,     const axutil_env_t * env)
{
   AXIS2_LOG_INFO(axis2_env->log,
"\n---OnRatingStubOpComplete()---\n");            ******* I see this in
the log
   isComplete = 1;
   return AXIS2_SUCCESS;
}

========================================================================
=============================

... In the trace execution goes into op_client.c here:

   if (args_list->callback)
   {
       axis2_callback_invoke_on_complete(args_list->callback, th_env,
args_list->op_client->async_result);    **** calls my on_complete
function above
       axis2_callback_set_complete(args_list->callback, th_env,
AXIS2_TRUE);
   }

   /* clean up memory */
   axis2_async_result_free(args_list->op_client->async_result, th_env);

   axis2_op_ctx_free(op_ctx, th_env);

   th_pool = th_env->thread_pool;

   AXIS2_FREE(th_env->allocator, args_list);

   if (th_env)
   {
       axutil_free_thread_env(th_env);
       th_env = NULL;
   }
   axutil_thread_pool_exit_thread(th_pool, thd);
***** this frees my env! as shown in my log
   return NULL;
}

========================================================================
=============================




So can someone tell me, is axis2_svc_client_send_receive_non_blocking
the wrong function to use if I want to make many service calls with one
environment?


Carl Lefrançois
Analyste / Programmeur
Larochelle Groupe Conseil

Tél. :      514-282-6817, poste 4548
Couriel : carl.lefrancois@axa-canada.com
 _____

"Ce message est confidentiel, à l'usage exclusif du destinataire
ci-dessus et son contenu ne représente en aucun cas un engagement de la
part de AXA, sauf en cas de stipulation expresse et par écrit de la part
de AXA. Toute publication, utilisation ou diffusion, même partielle,
doit être autorisée préalablement. Si vous n'êtes pas destinataire de ce
message, merci d'en avertir immédiatement l'expéditeur."

"This e-mail message is confidential, for the exclusive use of the
addressee and its contents shall not constitute a commitment by AXA,
except as otherwise specifically provided in writing by AXA. Any
unauthorized disclosure, use or dissemination, either whole or partial,
is prohibited. If you are not the intended recipient of the message,
please notify the sender immediately."

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-c-user-help@ws.apache.org





-- 
Software Engineer, WSO2 Inc
http://wso2.org

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-c-user-help@ws.apache.org


Re: RE : early env cleanup in asynchronous mode

Posted by Manjula Peiris <ma...@wso2.com>.
What is the Axis2/C version you are using ? Can you ran the client
through a memory profiling tool like valgrind and sent us the traces?  


On Mon, 2008-10-27 at 10:14 -0400, Lefrancois, Carl wrote:
> Thanks for your reply, Supun
> 
> I am hesitant to raise a Jira right away for two reasons: my version of Axis2/C is a few months old and I believe this behaviour may be right, and it is me who is calling the wrong function.  Are we sure there is a bug here?
> 
> Has anyone on the list made a client which uses the same env for many web service calls in asynchronous mode?  Maybe in this mode we need to create a new env for each call?
> 
> If I cannot find a better function and no one replies saying this should work, then a Jira could be a good idea.  I think this functionality is something Axis2/C should support.
> 
> 
> -Carl
> 
> 
> -----Message d'origine-----
> De : Supun Kamburugamuva [mailto:supun06@gmail.com] 
> Envoyé : samedi, octobre 25, 2008 00:37
> À : Apache AXIS C User List
> Objet : Re: early env cleanup in asynchronous mode
> 
> 
> Recently I got this error. But not sure what is happening exactly. Need to have a thorough look. Please create a Jira.
> 
> Supun.
> 
> 
> On Sat, Oct 25, 2008 at 12:27 AM, Lefrancois, Carl <Ca...@axa-canada.com> wrote:
> 
> Hello all,
> 
> No doubt my problem is due to user error, but I'm not sure what to try
> next to fix this problem.
> 
> I am working to implement asynchronous mode client calls in a project
> which is already fairly mature and works well in blocking mode.  When my
> DLL is loaded, I initialise the Axis2/C environment, and I free the
> environment on unload of the DLL.  In between I can make many web
> service calls in blocking mode.
> 
> What is happening now is that I used code from the echo_non_blocking.c
> sample to implement asynchronous mode but I get an access violation
> because the env is freed inside the function which calls my on_complete
> callback.  After this function is completed my application still tries
> to use the same env.
> 
> Can someone point out which function to call so I can make use of the
> asynchronous callbacks and still keep the same environment between
> calls?
> 
> 
> 
> 
> here is the code I am using:
> ========================================================================
> =============================
>      /* Send request */
>      svc_client = axis2_stub_get_svc_client (stub, axis2_env );
>      AXIS2_LOG_INFO(axis2_env->log, "\n---appel d'axis2 send receive
> INITIÉ---\n");  ******* I see this in the log
>      axis2_svc_client_send_receive_non_blocking(svc_client, axis2_env,
> payload, callback);
>      AXIS2_LOG_INFO(axis2_env->log, "\n---appel d'axis2 send receive
> RETOURNÉ---\n");******* I see this in the log
> 
>      /** Wait till callback is complete. Simply keep the parent thread
> running
>         until our on_complete or on_error is invoked */
>      while (count < 15)
>      {
>          if (isComplete)
>          {
>              /* We are done with the callback */
>              break;
>          }
>          AXIS2_LOG_INFO(axis2_env->log, "\n---AXIS DORT---\n");
> ******* I see this in the log
>          AXIS2_SLEEP(1);
>          AXIS2_LOG_INFO(axis2_env->log, "\n---AXIS SE RÉVEILLE---\n");
> ******* crash happens here after on_complete.. Axis2_env is freed!
>          count++;
>      }
> 
>      if (!(count < 15))
>      {
>        AXIS2_LOG_INFO(axis2_env->log, "\n---appel d'axis2 send receive
> COMPLÉTÉ TIMEOUT---\n");   **** never see this in log
>        *lpiEtatTraitement = ETAT_TRAITEMENT_TIMEOUT;
>      }
>      else
>      {
>        AXIS2_LOG_INFO(axis2_env->log, "\n---appel d'axis2 send receive
> COMPLÉTÉ OK---\n");        **** never see this in log
>      }
> ========================================================================
> =============================
> 
> 
> axis2_status_t AXIS2_CALL OnRatingStubOpComplete(     struct
> axis2_callback * callback,     const axutil_env_t * env)
> {
>    AXIS2_LOG_INFO(axis2_env->log,
> "\n---OnRatingStubOpComplete()---\n");            ******* I see this in
> the log
>    isComplete = 1;
>    return AXIS2_SUCCESS;
> }
> 
> ========================================================================
> =============================
> 
> ... In the trace execution goes into op_client.c here:
> 
>    if (args_list->callback)
>    {
>        axis2_callback_invoke_on_complete(args_list->callback, th_env,
> args_list->op_client->async_result);    **** calls my on_complete
> function above
>        axis2_callback_set_complete(args_list->callback, th_env,
> AXIS2_TRUE);
>    }
> 
>    /* clean up memory */
>    axis2_async_result_free(args_list->op_client->async_result, th_env);
> 
>    axis2_op_ctx_free(op_ctx, th_env);
> 
>    th_pool = th_env->thread_pool;
> 
>    AXIS2_FREE(th_env->allocator, args_list);
> 
>    if (th_env)
>    {
>        axutil_free_thread_env(th_env);
>        th_env = NULL;
>    }
>    axutil_thread_pool_exit_thread(th_pool, thd);
> ***** this frees my env! as shown in my log
>    return NULL;
> }
> 
> ========================================================================
> =============================
> 
> 
> 
> 
> So can someone tell me, is axis2_svc_client_send_receive_non_blocking
> the wrong function to use if I want to make many service calls with one
> environment?
> 
> 
> Carl Lefrançois
> Analyste / Programmeur
> Larochelle Groupe Conseil
> 
> Tél. :      514-282-6817, poste 4548
> Couriel : carl.lefrancois@axa-canada.com
>  _____
> 
> "Ce message est confidentiel, à l'usage exclusif du destinataire
> ci-dessus et son contenu ne représente en aucun cas un engagement de la
> part de AXA, sauf en cas de stipulation expresse et par écrit de la part
> de AXA. Toute publication, utilisation ou diffusion, même partielle,
> doit être autorisée préalablement. Si vous n'êtes pas destinataire de ce
> message, merci d'en avertir immédiatement l'expéditeur."
> 
> "This e-mail message is confidential, for the exclusive use of the
> addressee and its contents shall not constitute a commitment by AXA,
> except as otherwise specifically provided in writing by AXA. Any
> unauthorized disclosure, use or dissemination, either whole or partial,
> is prohibited. If you are not the intended recipient of the message,
> please notify the sender immediately."
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-c-user-help@ws.apache.org
> 
> 
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-c-user-help@ws.apache.org