You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by Jaro Gulo <jh...@yahoo.com.INVALID> on 2022/07/26 09:04:34 UTC

Qpid Proton 0.37.0, MultiThread, Reconnect

Hallo,
Could you please advise me about Qpid Proton 0.37.0 (C++)
I have 2 problems:
- Problem no.1: MemoryLeaks
- Problem no.2: Termination takes a long time

I use Proton-Client (Qpid Proton 0.37.0).
Problems can be simulated on the example "multithreaded_client.cpp" (https://qpid.apache.org/releases/qpid-proton-0.37.0/proton/cpp/examples/multithreaded_client.cpp.html), which is modified as follows:

void on_container_start(proton::container& cont) override
{
    proton::reconnect_options ReconnectOptions;
    ReconnectOptions.delay(proton::duration(20*1000)); //20Sec
    ReconnectOptions.delay_multiplier(1);

    cont.connect(url_, proton::connection_options().reconnect(ReconnectOptions));
}

void on_error(const proton::error_condition& e) override
{
    //Error is ignored
}

int main(int argc, const char** argv){    try
    {
        const char *url = argv[1];
        const char *address = argv[2];
        int n_messages = atoi(argv[3]);

        client cl(url, address);
        proton::container container(cl);
        std::thread container_thread([&]() { container.run(); });
        
        ::Sleep(10 * 1000); //Test - 10Sec wait
        
        container.stop();
        container_thread.join();

        return 0;
    }
    catch (const std::exception& e)
    {
        std::cerr << e.what() << std::endl;
    }

    return 1;
}

I simulate an error (so that a reconnect is made) -  I don't start the Broker (or I use the wrong IP-Address), so the Client reports an error. 
- Problem no.1 MemoryLeaks:
The client will try to reconnect. Each such Reconnect attempt creates a MemoryLeak:
pni_head_t *head vo funkcii pn_object_new (subor object.c, riadok pni_head_t *head = (pni_head_t *) pni_mem_zallocate(clazz, sizeof(pni_head_t) + size);)
 This function is called from the function pn_proactor_connect2 (win_iocp.cpp)
- Problem no.2, Termination takes a long time:
container_thread.join(); Duration from 0 to 20Sec (according to ReconnectOptions.delay(proton::duration(20*1000)))

Qpid Proton 0.37.0
VisualStudio 2015
Win10

Thank you
Horcik