Replaced the assert by a conditional
authorGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Fri, 3 Jun 2011 20:00:41 +0000 (17:00 -0300)
committerGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Fri, 3 Jun 2011 20:00:41 +0000 (17:00 -0300)
- because the amount of data received can differ from the amount we expect, but this cannot make the application to abort.

src/icmp/icmpmessagepayload.cpp

index 6a225ff..2de1fd9 100644 (file)
 
 #include <boost/assert.hpp>
 
+#include <logfunc.hpp>
+
 using namespace std;
 using boost::scoped_array;
+using I2n::Logger::GlobalLogger;
 
 //-----------------------------------------------------------------------------
 // IcmpMessagePayload
@@ -106,7 +109,12 @@ istream& IcmpMessagePayload::read( istream &is )
     char *data_array = reinterpret_cast<char *> ( Payload.get() );
     (void) is.read( data_array, PayloadSizeInBytes );
 
-    BOOST_ASSERT( static_cast<size_t>(is.gcount()) == PayloadSizeInBytes );
+    size_t data_received_in_bytes = static_cast<size_t>( is.gcount() );
+    if ( data_received_in_bytes != PayloadSizeInBytes )
+    {
+        GlobalLogger.error() << "Error: expecting " << PayloadSizeInBytes
+                << " bytes, but received " << is.gcount() << " bytes" << endl;
+    }
 
     return is;
 }