[openamq-dev] concurrent call of amq_client_connection_new()

Jörg Fischer joerg.fischer at biologie.uni-freiburg.de
Thu Jan 31 09:09:20 CET 2008


Hi Martin,

thanks for the fast reply. Here comes a piece of code that reproduces 
the effect.
I ran it with Visual Studio 2005 on a Win XP box. When I stop code 
execution,
a message box appears, telling me a deadlock occured. One thread is at 
location
'free', the other at 'apr_thread_mutex_lock'. The OpenAMQ version is 1.2c4.
If you need more informations to reproduce the deadlock, just ask.

Cheers,

Joerg

#ifndef WINVER
#define WINVER 0x0501
#endif
#include <afxwin.h>
#include <iostream>
#include <string>

#include <base.h>
#include <amq_client_connection.h>

using namespace std;

UINT run1(LPVOID)
{
    cout << "run 1 starting..." << endl;

    icl_longstr_t* auth_data  = amq_client_connection_auth_plain 
("guest", "guest");
    amq_client_connection_t* connection = 
amq_client_connection_new("1.2.3.4:1234", "/", auth_data, "client1", 0, 
5000);   
 
    Sleep(1000);

    amq_client_connection_destroy(&connection);
    cout << "run 1 done" << endl;
    return 0;
}

UINT run2(LPVOID)
{
    cout << "run 2 starting..." << endl;
   
    icl_longstr_t* auth_data  = amq_client_connection_auth_plain 
("guest", "guest");
    amq_client_connection_t* connection = 
amq_client_connection_new("1.2.3.4:1234", "/", auth_data, "client2", 0, 
5000);   
 
    Sleep(1000);

    amq_client_connection_destroy(&connection);
    cout << "run 2 done" << endl;
    return 0;
}

int main (int argc, char* argv[])
{
    icl_system_initialise(argc, argv);

    CWinThread* thread1 = AfxBeginThread(run1, 0);
    CWinThread* thread2 = AfxBeginThread(run2, 0);
 
    HANDLE handles[2];
    handles[0] = thread1->m_hThread;
    handles[1] = thread2->m_hThread;

    WaitForMultipleObjects(2, handles, TRUE, INFINITE);

    icl_system_terminate ();

    return 0;
}

Martin Sustrik schrieb:
> Hi,
>
> The thing you are doing should work ok. This looks like a bug. Do you 
> have a simple test program to reproduce the behaviour?
> In the meantime, as a workaround, just open the two connections 
> consecutively.
>
> Thanks for reporting the problem.
> Martin
>   



More information about the openamq-dev mailing list