summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReo Kimura <reo.kimura@mongodb.com>2022-01-13 18:39:00 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-02-23 15:57:15 +0000
commit72cc79fd427ffca414f11f7c4bdbf88bc12d1a1d (patch)
treeda42babdaac6ad628397e488fbf9b768e12e926b
parent68a49ec78738d5086b85f5656ec6db25b02e7210 (diff)
downloadmongo-72cc79fd427ffca414f11f7c4bdbf88bc12d1a1d.tar.gz
SERVER-61107 Serialize concurrent accesses to Socket in TCPResetAfterConnectionIsSilentlySwallowed
(cherry picked from commit c2eee2a284cf064b25b396f36331af19568a6425)
-rw-r--r--src/mongo/transport/transport_layer_asio_test.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/mongo/transport/transport_layer_asio_test.cpp b/src/mongo/transport/transport_layer_asio_test.cpp
index fd26a59f735..d08499e66f9 100644
--- a/src/mongo/transport/transport_layer_asio_test.cpp
+++ b/src/mongo/transport/transport_layer_asio_test.cpp
@@ -48,6 +48,7 @@
#include "mongo/transport/session_asio.h"
#include "mongo/transport/transport_options_gen.h"
#include "mongo/unittest/assert_that.h"
+#include "mongo/unittest/barrier.h"
#include "mongo/unittest/unittest.h"
#include "mongo/util/assert_util.h"
#include "mongo/util/concurrency/notification.h"
@@ -321,8 +322,13 @@ TEST(TransportLayerASIO, ListenerPortZeroTreatedAsEphemeral) {
connected.get();
}
+/**
+ * Test that the server appropriately handles a client-side socket disconnection, and that the
+ * client sends an RST packet when the socket is forcibly closed.
+ */
TEST(TransportLayerASIO, TCPResetAfterConnectionIsSilentlySwallowed) {
TestFixture tf;
+ unittest::Barrier barrier(2);
AtomicWord<int> sessionsCreated{0};
tf.sep().setOnStartSession([&](auto&&) { sessionsCreated.fetchAndAdd(1); });
@@ -341,8 +347,12 @@ TEST(TransportLayerASIO, TCPResetAfterConnectionIsSilentlySwallowed) {
auto err = make_error_code(std::errc{errno});
LOGV2_ERROR(6109517, "setsockopt", "error"_attr = err.message());
}
+ barrier.countDownAndWait();
});
fp.waitForTimesEntered(timesEntered + 1);
+ // Test case thread does not close socket until client thread has set options to ensure that an
+ // RST packet will be set on close.
+ barrier.countDownAndWait();
LOGV2(6109516, "closing");
connectThread.close();