summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmir Taaki <genjix@riseup.net>2014-03-17 13:13:06 (GMT)
committer Amir Taaki <genjix@riseup.net>2014-03-17 13:13:06 (GMT)
commit60c982c6cd3cc854acb15908ed575a14632af2f7 (patch)
treea5860d0a02255c09e7be2a175787952a54e7f43c
parent789ca3cccbba7f1367aeea58d107f9d480f641b8 (diff)
we cannot share sockets among multiple threads.
-rw-r--r--src/worker/worker.cpp11
-rw-r--r--src/worker/worker.hpp2
2 files changed, 7 insertions, 6 deletions
diff --git a/src/worker/worker.cpp b/src/worker/worker.cpp
index 143dce5..9893a5a 100644
--- a/src/worker/worker.cpp
+++ b/src/worker/worker.cpp
@@ -20,15 +20,16 @@ constexpr long poll_sleep_interval = 1000;
auto now = []() { return microsec_clock::universal_time(); };
send_worker::send_worker(czmqpp::context& context)
- : socket_(context, ZMQ_PUSH)
+ : context_(context)
{
- BITCOIN_ASSERT(socket_.self());
- int rc = socket_.connect("inproc://trigger-send");
- BITCOIN_ASSERT(rc == 0);
}
void send_worker::queue_send(const outgoing_message& message)
{
- message.send(socket_);
+ czmqpp::socket socket(context_, ZMQ_PUSH);
+ BITCOIN_ASSERT(socket.self());
+ int rc = socket.connect("inproc://trigger-send");
+ BITCOIN_ASSERT(rc == 0);
+ message.send(socket);
}
request_worker::request_worker()
diff --git a/src/worker/worker.hpp b/src/worker/worker.hpp
index cfe0b47..f9dc904 100644
--- a/src/worker/worker.hpp
+++ b/src/worker/worker.hpp
@@ -29,7 +29,7 @@ public:
void queue_send(const outgoing_message& message);
private:
- czmqpp::socket socket_;
+ czmqpp::context& context_;
};
class request_worker