Hi Samisa,
thank you for your reply.
May you tell me if these pseudo-code fragments are conceptually right?
Fragment 1)
Main thread:
start threads 1...N
Thread n:
create environment env[n]
create service client client_a[n] from env[n]
create service client client_b[n] from env[n]
create service client client_c[n] from env[n]
use service client client_a[n]
use service client client_b[n]
use service client client_c[n]
Fragment 2)
Main thread:
create environment env
start threads 1...N
Thread n:
create service client client_a[n] from env
create service client client_b[n] from env
create service client client_c[n] from env
use service client client_a[n]
use service client client_b[n]
use service client client_c[n]
Fragment 3)
Main thread:
create environment env
create service client client_a from env
create service client client_b from env
create service client client_c from env
start threads 1...N
Thread n:
use service client client_a
use service client client_b
use service client client_c
Whatever option I try, I still have A LOT of errors during C-Runtime
library function invocations. malloc returning null, user exceptions,
null pointers, heap corruption messages, ...
I still think there's something I'm missing, like calling an
initialization function at the beginning of a thread.
I develop on MFC framework, so I use CWinThread and AfxBeginThreads
(that encapsulate native Win32's CreateThread) to spawn new threads.
Another question, probably linked with heap corruption: strings! I use
axutil_string_create whenever I have to pass an axis's string, and I
pass string literal constants ("hello") or const char* whenever a
function needs an axis'2 char_t. I saw a similar usage in examples, but
these days, reading the mailing list, I saw you instead suggest strdup
and similar... What's the official "correct" way of handling string (and
in general, memory management)? I can't find it explained anywhere, and
I think it's a key point for every user/developer to avoid memory leaks.
Thanks!
Stefano
Samisa Abeysinghe wrote:
If you are using multiple service clients in the same program in
threads, you may have to disable the resetting on the libxml2 parser,
whenever you free the service client.
You can do this by using the method axis2_options_set_xml_parser_reset
and set that to AXIS2_FALSE.
HTH
Thanks,
Samisa...
Stefano Pettini wrote:
Hi,
I've just subscribed this mailing list since I really need your help
to better understand how to use Axis2/C in a multi-thread environment.
I only use the client side, and server side services are disabled in
axis2.xml.
I think there must be something I ignore about memory management and
threading support.
My web service client runs fine in a single-thread helloworld, but
crashes ALL THE TIME if I run a multi-thread software. In particular,
I believe I'm using Axis2's environments, allocator, and error
structures in an incorrect way, that's why I'm asking for more info.
Just to know the correct way of using _create, _free, AXIS2_FREE an
so on, if solves my problem.
Is it right to create an environment in each thread? Or should I
create a single environment and then create svc_clients in each
thread? Or create everything in the root thread and then invoke the
svc_clients from different threads?
I really did a lot of test: shared / not shared error_t structures, a
custom allocator with functions protected by a shared mutex, single
environment, many environments, but the results are always the same:
continuous random crashes in different points. After studying the
problem for 2 days, I've discovered malloc, realloc and free, of both
the custom and default allocator, sometimes fail returning null. So I
have null pointer exceptions everywhere randomly!
And I'm not doing anything special! I've setup 3 svc_clients in each
thread, 10 threads, without executing anything else, without even
calling the services! I can't imagine what happens if I execute the
send_receive!
I really don't know what to think. I defined a custom allocator,
shared among all the environments, with functions protected by a
mutex. malloc/free crashes were solved, but now I have readdir and
other function crashing all the time (crashing means int 3, user
exception and heap corruption), continuously and randomly.
Libxml2 is initialized by the main thread, as specified in libxml2's
documentation about multi-threading support.
I'm working with Win2003 x86, VC6 and the multi-thread debug dll C
runtime MSVCRTD.dll.
I run on a Core2 Duo, maybe it's too much multi-threading :-)
Thanks a lot if you can help me or suggest what to do next.
I have tons of info since I've studied Axis2 source very deeply.
If you want to know something more, just ask.
Cheers,
Stefano
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]