Skip to content

Commit c68755e

Browse files
committed
[Cleanup] Packet validator ensure DCP open only called once
The packet validator won't accept a DCP open to be called on a connection already set up as a DCP connection so the engine don't need to do the same check. Change-Id: Iaa2ee94805ef8acb7b315e19818512e10312b4f1 Reviewed-on: http://review.couchbase.org/c/kv_engine/+/140962 Tested-by: Build Bot <[email protected]> Reviewed-by: Jim Walker <[email protected]> Reviewed-by: Paolo Cocchi <[email protected]>
1 parent 0d40723 commit c68755e

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

engines/ep/src/ep_engine.cc

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6147,17 +6147,8 @@ ENGINE_ERROR_CODE EventuallyPersistentEngine::dcpOpen(
61476147
uint32_t flags,
61486148
std::string_view stream_name,
61496149
std::string_view value) {
6150-
(void) opaque;
6151-
(void) seqno;
61526150
std::string connName{stream_name};
6153-
6154-
auto* handler = getConnHandler(cookie);
6155-
if (handler) {
6156-
EP_LOG_WARN(
6157-
"Cannot open DCP connection as another connection exists on "
6158-
"the same socket");
6159-
return ENGINE_DISCONNECT;
6160-
}
6151+
ConnHandler* handler = nullptr;
61616152

61626153
if (flags & (cb::mcbp::request::DcpOpenPayload::Producer |
61636154
cb::mcbp::request::DcpOpenPayload::Notifier)) {

tests/testapp/testapp_dcp.cc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,18 @@ TEST_P(DcpTest, MB35928_DcpCantReauthenticate) {
162162
<< "SASL AUTH should fail";
163163
}
164164
}
165+
166+
TEST_P(DcpTest, CantDcpOpenTwice) {
167+
auto& conn = getAdminConnection();
168+
conn.selectBucket("default");
169+
auto rsp = conn.execute(BinprotDcpOpenCommand{
170+
"ewb_internal:1", cb::mcbp::request::DcpOpenPayload::Producer});
171+
ASSERT_TRUE(rsp.isSuccess());
172+
173+
rsp = conn.execute(BinprotDcpOpenCommand{
174+
"ewb_internal:1", cb::mcbp::request::DcpOpenPayload::Producer});
175+
ASSERT_FALSE(rsp.isSuccess());
176+
auto json = nlohmann::json::parse(rsp.getDataString());
177+
EXPECT_EQ("The connection is already opened as a DCP connection",
178+
json["error"]["context"]);
179+
}

0 commit comments

Comments
 (0)