1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-08-11 13:20:34 +00:00
This commit is contained in:
Carles Fernandez 2019-09-29 13:01:35 +02:00
commit 42c1a3a1b4
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D

View File

@ -40,7 +40,6 @@
#include <boost/dynamic_bitset.hpp> #include <boost/dynamic_bitset.hpp>
#include <boost/exception/diagnostic_information.hpp> #include <boost/exception/diagnostic_information.hpp>
#include <algorithm> // for std::reverse #include <algorithm> // for std::reverse
#include <chrono> // std::chrono::seconds
#include <cmath> // for std::fmod, std::lround #include <cmath> // for std::fmod, std::lround
#include <cstdlib> // for strtol #include <cstdlib> // for strtol
#include <iostream> // for cout #include <iostream> // for cout
@ -89,12 +88,9 @@ void Rtcm::run_server()
std::cout << "Starting a TCP/IP server of RTCM messages on port " << RTCM_port << std::endl; std::cout << "Starting a TCP/IP server of RTCM messages on port " << RTCM_port << std::endl;
try try
{ {
std::thread tq([&] { std::make_shared<Queue_Reader>(io_context, rtcm_message_queue, RTCM_port)->do_read_queue(); }); tq = std::thread([&] { std::make_shared<Queue_Reader>(io_context, rtcm_message_queue, RTCM_port)->do_read_queue(); });
tq.detach(); t = std::thread([&] { io_context.run(); });
std::thread t([&] { io_context.run(); });
server_is_running = true; server_is_running = true;
t.detach();
} }
catch (const std::exception& e) catch (const std::exception& e)
{ {
@ -112,10 +108,11 @@ void Rtcm::stop_service()
void Rtcm::stop_server() void Rtcm::stop_server()
{ {
std::cout << "Stopping TCP/IP server on port " << RTCM_port << std::endl; std::cout << "Stopping TCP/IP server on port " << RTCM_port << std::endl;
rtcm_message_queue->push("Goodbye"); // this terminates tq
Rtcm::stop_service(); Rtcm::stop_service();
servers.front().close_server(); servers.front().close_server();
std::this_thread::sleep_for(std::chrono::seconds(1)); rtcm_message_queue->push("Goodbye"); // this terminates tq
tq.join();
t.join();
server_is_running = false; server_is_running = false;
} }