Hi,
You can keep a global flag to set when the callback is finish calling. and
may be in a while loop you can check that flag and free if it is set. I'm
not sure whether this fit to your application. Another option is passing
stub as the data in the callback and free it.

But you can't free the env variable either way. That's should be created at
the start of the app and free at the end of it. Anyway if you want to do
that you may have to edit the generated stub call.

Thanks
Dimuthu

On Mon, Dec 8, 2008 at 4:06 PM, Patrick van Beem <
[EMAIL PROTECTED]> wrote:

> Hello,
>
> I'm planning to use axis a lot in an asynchronous way in a multi-threaded
> server environment. Therefore, it is very important for me to not have any
> memory (resource) leaks. When using axis in an asynchronous way, I don't
> manage to free all my resources in a safe way.  I'm using axis2/c with adb
> data binding. Here's my problem:
>
> Assume I use the following pseudo code:
>
> struct resources
> {
>  axutil_env_t* m_env;
>  axis2_stub_t* m_stub;
> };
>
> static axis2_status_t AXIS2_CALL on_complete(const axutil_env_t* env,
> adb_addResponse_t* response, void* data)
> {
>  struct resources* res = reinterpret_cast<struct resources*>(data);
>
>  /* Use a critical to prevent too early freeing, do some usefull things....
> */
>  FreeAllocatedResources(res);
>
>  return AXIS2_SUCCESS;
> }
>
> CalcAsync()
> {
>  struct resources* res = AllocateAndInitializeResources();
>  adb_add_t* call = adb_add_create(res->m_env);
>  /* The real code uses a critical section here to prevent res being freed
> before the adb_add_free() is called) */
>  axis2_stub_start_op_Calculator_add(res->m_stub, res->m_env, call, res,
> on_complete, on_error);
>  adb_add_free(call, res->m_env);
> }
>
> The main test program initiates a 100 calls and then just waits.
>
> The problem is that when I free the resources in the callback (freeing the
> environment and the stub), the system crashes when it exits the thread
> created by axis for the async call. But this is the only place I can free
> the resources, because it's only here that I know the call finished!
> What's the usage pattern on freeing resources on async axis calls?
>
> Regards,
>
> --
>
>
> Patrick van Beem
> Sr. Software engineer
>
> Quintiq
>
> T +31 (0) 73 691 07 39
> F +31 (0) 73 691 07 54
> M +31 (0) 06 15 01 65 83
> E [EMAIL PROTECTED]
> I www.quintiq.com
>
>
>
> This message contains information that may be privileged or confidential
> and is the property of Quintiq. It is only intended for the person to whom
> it is addressed. If you are not the intended recipient, you are not
> authorized to read, print, retain, copy, disseminate, distribute or use this
> message or any part thereof. If you have received this message in error,
> please notify the sender immediately and delete all copies of this message.
> Please note that e-mails are susceptible to change, therefore they are not
> binding.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-- 
Thanks,
Dimuthu Gamage

http://www.dimuthu.org
http://www.wso2.org

Reply via email to