Hello,
I adapted the code like we said in the last meeting and it worked without
crashes.
So the rule that i deduce is that "we cannot copy any proton objet outside
of the handler's class".
I attached the corrected code for future reference.
Thanks,
Rabih
On Wed, Mar 27, 2019 at 5:19 PM Rabih M <[email protected]> wrote:
> Hello,
>
>
>
> I am using proton cpp version 0.27.0.
>
> We found a random failure in our code in proton sometime ago.
>
> I was able to reproduce using simple code against a java broker. Please
> find attached the code and the stack.
>
> The frequency is lower with the simplified code but we are still
> encountering the crash before reaching 60 000 repetitions.
>
>
>
> Murex will be using Proton and we need to ensure we have no such failure
> before using the code in production.
>
>
>
> Can you please advise?
>
> Do you need me to create a Jira issue?
>
>
>
> Best regards,
>
> Rabih
>
#include <proton/connection.hpp>
#include <proton/container.hpp>
#include <proton/messaging_handler.hpp>
#include <iostream>
#include <thread>
class handler : public proton::messaging_handler {
public:
handler(const std::string& u) : m_url(u) {}
proton::connection m_con;
std::promise<void> m_startProm;
std::promise<void> m_closeProm;
private:
void on_connection_open(proton::connection& c)override{
m_con = c;
m_startProm.set_value();
}
void on_connection_close(proton::connection&)override{
m_closeProm.set_value();
}
std::string m_url;
};
int main () {
{
try {
std::string url("//127.0.0.1:5672");
handler h(url);
proton::container c(h);
std::thread clientThread([&]() {
try
{
c.run();
}
catch (const std::exception& e) {
std::cerr << "Broker threw exception: " << e.what() << std::endl;
}});
c.connect(url);
h.m_startProm.get_future().get();
h.m_con.work_queue().add([&]() { h.m_con.close(); });
h.m_closeProm.get_future().get();
if (clientThread.joinable()) {
clientThread.join();
}
}
catch (std::exception& e) {
std::cerr << e.what() << std::endl;
}
return 0;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]