[openamq-dev] dead-lock in amq_client_connection_new
Dmitri Tsyganov
dmitri.tsyganov at dowjones.com
Thu May 8 23:07:05 CEST 2008
Hello,
I came across a problem, which appears to be a dead-lock in
amq_client_connection_new. I assume that amq_client_connection_new
function meant to be thread-safe.
I have a client app that opens OpenaAMQ connections on two separate
threads. Two threads start back-to-back. I noticed that sometime my
application (on some machines - all the time) blocks when it calls
amq_client_connection_new.
I think I found the problem:
1. two concurrent threads enter amq_client connection_new
2. s_amq_client_connection_active flag is false, so both threads one by
one enter self_initialize (amq_client_connection_initialize), line 320,
amq_client_connection.c
3. inside ..._initialize s_amq_client_connection_active still false and
first thread acquires icl_global_mutex lock, second thread waits on
icl_global_mutex.
4. first thread creates and locks s_amq_client_connection_mutex,
releases icl_global_mutex... second thread enters (locks)
icl_global_mutex and waits on s_amq_client_connection_mutex lock (owned
by 1st thread).
5. first thread calls smt_initialize (line 1666)
6. Inside smt_initialize - smt_os_thread.c, line 1646 - it blocked on
icl_global_mutex, still owned by the second thread - Dead-Lock!
I think I've seen similar code in amq_client_session_new... and probably
some other places.
Sincerely,
Dmitri
More information about the openamq-dev
mailing list