summaryrefslogtreecommitdiff
path: root/controller
diff options
context:
space:
mode:
authorGrant Limberg <grant.limberg@zerotier.com>2019-03-08 10:29:36 -0800
committerGrant Limberg <grant.limberg@zerotier.com>2019-03-08 10:29:36 -0800
commitcda07b20a26c0ac774445da1334234aab342ce63 (patch)
tree4ef8fbcb162dc671cb5cb5e4735a102465c9e87b /controller
parent52c85aa605e943b86b66c19bed0659e52aac31a0 (diff)
downloadinfinitytier-cda07b20a26c0ac774445da1334234aab342ce63.tar.gz
infinitytier-cda07b20a26c0ac774445da1334234aab342ce63.zip
add mutex to channel numbering
Diffstat (limited to 'controller')
-rw-r--r--controller/RabbitMQ.cpp7
-rw-r--r--controller/RabbitMQ.hpp6
2 files changed, 10 insertions, 3 deletions
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 <amqp.h>
#include <amqp_tcp_socket.h>
#include <string>
@@ -65,6 +66,9 @@ private:
int _status;
int _channel;
+
+ Mutex _chan_m;
+
};
}