Skip to content

Commit 7480be8

Browse files
owend74chiyoung
authored andcommitted
MB-19033 Allow connections of the same name
It was thought that connections would not exist in the connection map with the same name. However the view code does create connections of the same name. As we index on the connection object (cookie) as opposed to the name, we can relax the constraints to allow connections of the same name. Change-Id: I721c4d409d7f02119af534cbf1d887d9e65246c3 Reviewed-on: http://review.couchbase.org/62361 Reviewed-by: Chiyoung Seo <[email protected]> Tested-by: buildbot <[email protected]>
1 parent 6b900ac commit 7480be8

File tree

2 files changed

+8
-22
lines changed

2 files changed

+8
-22
lines changed

src/connmap.cc

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -935,15 +935,6 @@ DcpConsumer *DcpConnMap::newConsumer(const void* cookie,
935935
std::string conn_name("eq_dcpq:");
936936
conn_name.append(name);
937937

938-
for (const auto conn: all) {
939-
if (conn->getName() == conn_name) {
940-
LOG(EXTENSION_LOG_WARNING,
941-
"Failed to create Dcp Consumer because connection of the "
942-
"same name (%s) already exists", conn_name.c_str());
943-
return nullptr;
944-
}
945-
}
946-
947938
if (map_.count(cookie) != 0) {
948939
LOG(EXTENSION_LOG_WARNING,
949940
"Failed to create Dcp Consumer because connection "
@@ -1000,15 +991,6 @@ DcpProducer *DcpConnMap::newProducer(const void* cookie,
1000991
std::string conn_name("eq_dcpq:");
1001992
conn_name.append(name);
1002993

1003-
for (const auto conn: all) {
1004-
if (conn->getName() == conn_name) {
1005-
LOG(EXTENSION_LOG_WARNING,
1006-
"Failed to create Dcp Producer because connection of the "
1007-
"same name (%s) already exists", conn_name.c_str());
1008-
return nullptr;
1009-
}
1010-
}
1011-
1012994
if (map_.count(cookie) != 0) {
1013995
LOG(EXTENSION_LOG_WARNING,
1014996
"Failed to create Dcp Producer because connection "

tests/module_tests/dcp_test.cc

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,14 +351,16 @@ TEST_F(ConnectionTest, test_mb17042_duplicate_name_producer_connections) {
351351
struct mock_connstruct* cookie2 = (struct mock_connstruct*)create_mock_cookie();
352352
// Create a new Dcp producer
353353
dcp_producer_t producer = connMap.newProducer(cookie1, "test_producer",
354-
/*notifyOnly*/false);
354+
/*notifyOnly*/false);
355+
EXPECT_NE(0, (int)producer) << "producer is null";
355356

356357
// Create a duplicate Dcp producer
357358
dcp_producer_t duplicateproducer = connMap.newProducer(cookie2, "test_producer",
358-
/*notifyOnly*/false);
359-
EXPECT_EQ(0, (int)duplicateproducer) << "duplicateproducer is not null";
359+
/*notifyOnly*/false);
360+
EXPECT_NE(0, (int)duplicateproducer) << "duplicateproducer is null";
360361

361362
producer.reset();
363+
duplicateproducer.reset();
362364
delete cookie1;
363365
delete cookie2;
364366
}
@@ -370,12 +372,14 @@ TEST_F(ConnectionTest, test_mb17042_duplicate_name_consumer_connections) {
370372
struct mock_connstruct* cookie2 = (struct mock_connstruct*)create_mock_cookie();
371373
// Create a new Dcp consumer
372374
dcp_consumer_t consumer = connMap.newConsumer(cookie1, "test_consumer");
375+
EXPECT_NE(0, (int)consumer) << "consumer is null";
373376

374377
// Create a duplicate Dcp consumer
375378
dcp_consumer_t duplicateconsumer = connMap.newConsumer(cookie2, "test_consumer");
376-
EXPECT_EQ(0, (int)duplicateconsumer) << "duplicateconsumer is not null";
379+
EXPECT_NE(0, (int)duplicateconsumer) << "duplicateconsumer is null";
377380

378381
consumer.reset();
382+
duplicateconsumer.reset();
379383
delete cookie1;
380384
delete cookie2;
381385
}

0 commit comments

Comments
 (0)