Browse Source

[2187] Catch exceptions in perfdhcp if packet reception failed.

Marcin Siodelski 12 years ago
parent
commit
bbf34f3ba1
1 changed files with 14 additions and 2 deletions
  1. 14 2
      tests/tools/perfdhcp/test_control.cc

+ 14 - 2
tests/tools/perfdhcp/test_control.cc

@@ -784,7 +784,13 @@ TestControl::receivePackets(const TestControlSocket& socket) {
     uint64_t received = 0;
     while (receiving) {
         if (CommandOptions::instance().getIpVersion() == 4) {
-            Pkt4Ptr pkt4 = IfaceMgr::instance().receive4(timeout);
+            Pkt4Ptr pkt4;
+            try {
+                pkt4 = IfaceMgr::instance().receive4(timeout);
+            } catch (const Exception& e) {
+                std::cout << "Failed to receive DHCPv4 packet: "
+                          << e.what() <<  std::endl;
+            }
             if (!pkt4) {
                 receiving = false;
             } else {
@@ -796,7 +802,13 @@ TestControl::receivePackets(const TestControlSocket& socket) {
                 processReceivedPacket4(socket, pkt4);
             }
         } else if (CommandOptions::instance().getIpVersion() == 6) {
-            Pkt6Ptr pkt6 = IfaceMgr::instance().receive6(timeout);
+            Pkt6Ptr pkt6;
+            try {
+                pkt6 = IfaceMgr::instance().receive6(timeout);
+            } catch (const Exception& e) {
+                std::cout << "Failed to receive DHCPv6 packet: "
+                          << e.what() << std::endl;
+            }
             if (!pkt6) {
                 receiving  = false;
             } else {