From: Guilherme Maciel Ferreira Date: Tue, 2 Aug 2011 10:40:33 +0000 (-0300) Subject: Placed start_receive() method closer to the schedule_timeout_echo_reply(), where... X-Git-Tag: v1.1^2~32 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=5d5e4dcb861d26458beb2fca5a4e3a2a5affd85c;p=pingcheck Placed start_receive() method closer to the schedule_timeout_echo_reply(), where it gets called. --- diff --git a/src/icmp/icmppinger.cpp b/src/icmp/icmppinger.cpp index 6440660..e7c31dd 100644 --- a/src/icmp/icmppinger.cpp +++ b/src/icmp/icmppinger.cpp @@ -186,18 +186,6 @@ void IcmpPinger::schedule_timeout_echo_reply() ); } -void IcmpPinger::start_receive() -{ - // Discard any data already in the buffer. - ReplyBuffer.consume( ReplyBuffer.size() ); - - // Waiting for a reply. We prepare the buffer to receive up to 64KB. - Socket.async_receive( - ReplyBuffer.prepare( 65536 ), - boost::bind( &IcmpPinger::handle_receive_icmp_packet, this, _2 ) - ); -} - /** * @brief Gets called when the ping is finished: Either on timeout or on ping reply * @@ -219,6 +207,18 @@ void IcmpPinger::handle_ping_done() PingDoneCallback(ping_success); } +void IcmpPinger::start_receive() +{ + // Discard any data already in the buffer. + ReplyBuffer.consume( ReplyBuffer.size() ); + + // Waiting for a reply. We prepare the buffer to receive up to 64KB. + Socket.async_receive( + ReplyBuffer.prepare( 65536 ), + boost::bind( &IcmpPinger::handle_receive_icmp_packet, this, _2 ) + ); +} + /** * @brief Receive ICMP packets * Note: Will receive -all- ICMP packets from the kernel. So if the packet doesn't match diff --git a/src/icmp/icmppinger.h b/src/icmp/icmppinger.h index 3c807f6..35cdef3 100644 --- a/src/icmp/icmppinger.h +++ b/src/icmp/icmppinger.h @@ -55,10 +55,10 @@ private: IcmpPacket create_echo_request( const uint16_t sequence_number ) const; void send_echo_request( const IcmpPacket &icmp_packet ); void schedule_timeout_echo_reply(); + void handle_ping_done(); void start_receive(); void handle_receive_icmp_packet( const std::size_t &bytes_transferred ); - void handle_ping_done(); void print_echo_reply( const IcmpPacket &icmp_packet,