TimeSent + seconds( RstReplyTimeoutInSec )
);
TcpSegmentReceiveTimer.async_wait(
- boost::bind( &TcpPinger::handle_timeout, this )
+ boost::bind( &TcpPinger::handle_ping_done, this )
);
}
-void TcpPinger::handle_timeout()
+/**
+ * @brief Gets called when the ping is finished: Either on timeout or on ping reply
+ *
+ * @return void
+ **/
+void TcpPinger::handle_ping_done()
{
- ReceivedReply = false;
- TcpSegmentReceiveTimer.expires_at(
- TimeSent + seconds( RstReplyTimeoutInSec )
- );
- TcpSegmentReceiveTimer.async_wait(
- boost::bind( &TcpPinger::start_send, this )
- );
+ // Check ReceivedReply as the timer handler
+ // is also called by Timer.cancel();
+ if ( ReceivedReply == false )
+ {
+ GlobalLogger.info() << "Request timed out" << endl;
+
+ set_ping_status( PingStatus_FailureTimeout );
+ }
+
+ // Call ping-done handler
+ bool ping_success = (PingerStatus == PingStatus_SuccessReply);
+ PingDoneCallback(ping_success);
}
void TcpPinger::start_receive()
) const;
void send_ack_request( const TcpHeader &tcp_header );
void schedule_timeout_rst_reply();
- void handle_timeout();
+ void handle_ping_done();
void start_receive();
void handle_receive_tcp_segment( const std::size_t &bytes_transferred );