aboutsummaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorMauro Sardara <msardara@cisco.com>2019-01-29 15:49:15 +0100
committerMichele Papalini <micpapal@cisco.com>2019-01-29 17:30:27 +0000
commit51ff9b669dff18c9300b9fe5bdef91e7040edac0 (patch)
tree286625282289580594c0ecf7dcf3df47a7ed8a18 /utils
parenta2e898eae8086cded2acfa96347184b3aa88d316 (diff)
[HICN-17] Add possibility to destroy connection directly from stopEventsLoop with an additional parameter.
Change-Id: I869a079a7b2f436768a62de66fd9281a7d1243cd Signed-off-by: Mauro Sardara <msardara@cisco.com>
Diffstat (limited to 'utils')
-rwxr-xr-xutils/src/ping_client.cc13
1 files changed, 8 insertions, 5 deletions
diff --git a/utils/src/ping_client.cc b/utils/src/ping_client.cc
index e98a8b422..24f7bd7c9 100755
--- a/utils/src/ping_client.cc
+++ b/utils/src/ping_client.cc
@@ -76,13 +76,15 @@ class Configuration {
class Client : interface::BasePortal::ConsumerCallback {
public:
- Client(Configuration *c) : portal_() {
+ Client(Configuration *c)
+ : portal_(),
+ signals_(portal_.getIoService(), SIGINT, SIGQUIT) {
// Let the main thread to catch SIGINT and SIGQUIT
- // asio::signal_set signals(io_service, SIGINT, SIGQUIT);
- // signals.async_wait(std::bind(&Client::afterSignal, this));
-
portal_.connect();
portal_.setConsumerCallback(this);
+
+ signals_.async_wait(std::bind(&Client::afterSignal, this));
+
timer_.reset(new asio::steady_timer(portal_.getIoService()));
config_ = c;
sequence_number_ = config_->first_suffix_;
@@ -272,7 +274,7 @@ class Client : interface::BasePortal::ConsumerCallback {
std::cout << "Stop ping" << std::endl;
std::cout << "Sent: " << sent_ << " Received: " << received_
<< " Timeouts: " << timedout_ << std::endl;
- portal_.stopEventsLoop();
+ portal_.stopEventsLoop(true);
}
void reset() {
@@ -289,6 +291,7 @@ class Client : interface::BasePortal::ConsumerCallback {
private:
SendTimeMap send_timestamps_;
interface::BasePortal portal_;
+ asio::signal_set signals_;
uint64_t sequence_number_;
uint64_t last_jump_;
uint64_t processed_;