axis-c-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Patrick van Beem" <>
Subject [axis2/c] When to free what resources in an async adb call?
Date Mon, 08 Dec 2008 10:36:55 GMT

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.... */

  return AXIS2_SUCCESS;

  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,
  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?



Patrick van Beem
Sr. Software engineer
T +31 (0) 73 691 07 39
F +31 (0) 73 691 07 54
M +31 (0) 06 15 01 65 83

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:
For additional commands, e-mail:

View raw message