Bug 925337 - Make TestStunServer dtor safe if listen_sock_ is null. r=abr
authorEKR <ekr@rtfm.com>
Thu, 10 Oct 2013 07:08:18 -0700
changeset 164180 701758a4010d500fe5d395118db513548db5c79b
parent 164179 44eee084be1d44dc09992cc8d224437f4b8e7c9c
child 164181 cff5a22acb7c81cf373a85a3de08c480999ed550
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersabr
bugs925337
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 925337 - Make TestStunServer dtor safe if listen_sock_ is null. r=abr
media/mtransport/test/stunserver.cpp
--- a/media/mtransport/test/stunserver.cpp
+++ b/media/mtransport/test/stunserver.cpp
@@ -181,19 +181,21 @@ int nr_socket_wrapped_create(nr_socket *
 // we have no reason to expect this will be initted to a nullptr yet.
 TestStunServer* TestStunServer::instance;
 uint16_t TestStunServer::instance_port = 3478;
 
 TestStunServer::~TestStunServer() {
   // TODO(ekr@rtfm.com): Put this on the right thread.
 
   // Unhook callback from our listen socket.
-  NR_SOCKET fd;
-  if (!nr_socket_getfd(listen_sock_, &fd)) {
-    NR_ASYNC_CANCEL(fd, NR_ASYNC_WAIT_READ);
+  if (listen_sock_) {
+    NR_SOCKET fd;
+    if (!nr_socket_getfd(listen_sock_, &fd)) {
+      NR_ASYNC_CANCEL(fd, NR_ASYNC_WAIT_READ);
+    }
   }
 
   // Free up stun context and network resources
   nr_stun_server_ctx_destroy(&stun_server_);
   nr_socket_destroy(&listen_sock_);
   nr_socket_destroy(&send_sock_);
 
   // Make sure we aren't still waiting on a deferred response timer to pop