Skip to content

Commit

Permalink
Fixed thread termination
Browse files Browse the repository at this point in the history
  • Loading branch information
SAtacker committed Mar 10, 2021
1 parent 5eb3117 commit 8d07fab
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cpp_app/data_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void datahandler::start_slt(bool _start)
a =new boost::asio::ip::tcp::acceptor(io_service,boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(),2121));
a->accept(*tcp_socket);
init_server();
boost::thread th([this]{this->spin();});
th =new boost::thread([this]{this->spin();});
}
}

Expand All @@ -100,9 +100,11 @@ void datahandler::close_slt(bool _close)
tcp_socket->shutdown(tcp_socket->shutdown_both);
tcp_socket->close();
udp_socket->close();
th->interrupt();
delete a;
delete tcp_socket;
delete udp_socket;
delete th;
}
}

Expand Down
1 change: 1 addition & 0 deletions cpp_app/data_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public slots:
boost::asio::ip::udp::socket *udp_socket;
pid_terms_incomming_values vals;
boost::asio::ip::tcp::acceptor *a;
boost::thread *th;
};

#endif // DATA_HANDLER_H

0 comments on commit 8d07fab

Please sign in to comment.