Skip to content

Commit

Permalink
DEVOPS-10175 connection thread stopvar
Browse files Browse the repository at this point in the history
  • Loading branch information
ipalenov committed Jun 5, 2024
1 parent 4150b5b commit 9fa084e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/linux/ConnectionImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <condition_variable>

ConnectionImpl::ConnectionImpl(const AMQP::Address& address) :
trChannel(nullptr)
trChannel(nullptr), stop(false)
{
static bool sslInited = false;
if (!sslInited){
Expand All @@ -20,9 +20,7 @@ ConnectionImpl::ConnectionImpl(const AMQP::Address& address) :

ConnectionImpl::~ConnectionImpl() {
closeChannel(trChannel);
if (!connection->closed()){
connection->close();
}
stop = true;
event_base_loopbreak(eventLoop);
thread.join();
connection.reset(nullptr);
Expand All @@ -33,7 +31,7 @@ ConnectionImpl::~ConnectionImpl() {

void ConnectionImpl::loopThread(ConnectionImpl* thiz) {
event_base* loop = thiz->eventLoop;
while(!thiz->connection->closed()) {
while(!thiz->stop) {
try{
event_base_loop(loop, EVLOOP_NONBLOCK);
}catch(std::exception& ex){
Expand Down
1 change: 1 addition & 0 deletions src/linux/ConnectionImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ class ConnectionImpl{

std::unique_ptr<AMQP::TcpChannel> trChannel;
std::thread thread;
volatile bool stop;
};

0 comments on commit 9fa084e

Please sign in to comment.