Browse Source

[master] Corrected valgrind complaint in dhcpsrv unittest.

Thomas Markwalder 11 years ago
parent
commit
3ccbb10693
2 changed files with 11 additions and 0 deletions
  1. 6 0
      src/lib/dhcpsrv/d2_client.h
  2. 5 0
      src/lib/dhcpsrv/tests/d2_udp_unittest.cc

+ 6 - 0
src/lib/dhcpsrv/d2_client.h

@@ -382,6 +382,12 @@ public:
     /// supplied as the manager cannot know how an application should deal
     /// with send failures.
     /// @param io_service IOService to be used for sender IO event processing
+    /// @warning It is up to the invoking layer to ensure the io_service
+    /// instance used outlives the D2ClientMgr send mode. When the send mode
+    /// is exited, either expliclity by callind stopSender() or implicitly
+    /// through D2CLientMgr destruction, any ASIO objects such as sockets or
+    /// timers will be closed and released.  If the io_service goes out of scope
+    /// first this behavior could be unpredictable.
     ///
     /// @throw D2ClientError if sender instance is null. Underlying layer
     /// may throw NCRSenderExceptions exceptions.

+ 5 - 0
src/lib/dhcpsrv/tests/d2_udp_unittest.cc

@@ -319,6 +319,11 @@ TEST_F(D2ClientMgrTest, udpSendExternalIOService) {
 
     // select_fd should evaluate to not ready to read.
     selectCheck(false);
+
+    // Explicitly stop the sender. This ensures the sender's
+    // ASIO socket is closed prior to the local io_service
+    // instance goes out of scope.
+    ASSERT_NO_THROW(stopSender());
 }
 
 /// @brief Checks that D2ClientMgr invokes the client error handler