transport: Fix segfault when transport is closed while multiple send operations are scheduled

Change-Id: Icf6158150c9b6c2c17a89c01fc883eaf003e356e
Refs: #3136
diff --git a/tests/integrated/face.cpp b/tests/integrated/face.cpp
index b166edf..3a5f071 100644
--- a/tests/integrated/face.cpp
+++ b/tests/integrated/face.cpp
@@ -496,6 +496,21 @@
   BOOST_CHECK_EQUAL(nTimeouts, 4);
 }
 
+BOOST_AUTO_TEST_CASE(ShutdownWhileSendInProgress) // Bug #3136
+{
+  Face face;
+  face.expressInterest(Name("/Hello/World/!"), bind([]{}), bind([]{}));
+  BOOST_REQUIRE_NO_THROW(face.processEvents(time::seconds(1)));
+
+  face.expressInterest(Name("/Bye/World/1"), bind([]{}), bind([]{}));
+  face.expressInterest(Name("/Bye/World/2"), bind([]{}), bind([]{}));
+  face.expressInterest(Name("/Bye/World/3"), bind([]{}), bind([]{}));
+  face.shutdown();
+
+  BOOST_REQUIRE_NO_THROW(face.processEvents(time::seconds(1)));
+  // should not segfault
+}
+
 BOOST_AUTO_TEST_SUITE_END()
 
 } // tests