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]