From cda07b20a26c0ac774445da1334234aab342ce63 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Fri, 8 Mar 2019 10:29:36 -0800 Subject: add mutex to channel numbering --- controller/RabbitMQ.cpp | 7 +++++-- controller/RabbitMQ.hpp | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'controller') diff --git a/controller/RabbitMQ.cpp b/controller/RabbitMQ.cpp index 096d3f53..f5a5c1d6 100644 --- a/controller/RabbitMQ.cpp +++ b/controller/RabbitMQ.cpp @@ -48,7 +48,10 @@ void RabbitMQ::init() } static int chan = 0; - _channel = ++chan; + { + Mutex::Lock l(_chan_m); + _channel = ++chan; + } amqp_channel_open(_conn, _channel); r = amqp_get_rpc_reply(_conn); if(r.reply_type != AMQP_RESPONSE_NORMAL) { @@ -88,4 +91,4 @@ std::string RabbitMQ::consume() return msg; } -} \ No newline at end of file +} diff --git a/controller/RabbitMQ.hpp b/controller/RabbitMQ.hpp index 74023b12..d341681b 100644 --- a/controller/RabbitMQ.hpp +++ b/controller/RabbitMQ.hpp @@ -36,9 +36,10 @@ struct MQConfig { }; } - #ifdef ZT_CONTROLLER_USE_LIBPQ +#include "../node/Mutex.hpp" + #include #include #include @@ -65,6 +66,9 @@ private: int _status; int _channel; + + Mutex _chan_m; + }; } -- cgit v1.2.3