Skip to content

Commit 3646e24

Browse files
author
Laura Flores
committed
Revert "msg/async/ProtocolV[12]: unlock the write_lock before doing I/O"
This reverts commit f07cd30. The PR was mistakenly merged after some regressions were found in teuthology. Signed-off-by: Laura Flores <[email protected]>
1 parent aaee958 commit 3646e24

File tree

2 files changed

+4
-24
lines changed

2 files changed

+4
-24
lines changed

src/msg/async/ProtocolV1.cc

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ void ProtocolV1::send_message(Message *m) {
222222
is_prepared = true;
223223
}
224224

225-
std::unique_lock l{connection->write_lock};
225+
std::lock_guard<std::mutex> l(connection->write_lock);
226226
// "features" changes will change the payload encoding
227227
if (can_fast_prepare &&
228228
(can_write == WriteStatus::NOWRITE || connection->get_features() != f)) {
@@ -245,11 +245,6 @@ void ProtocolV1::send_message(Message *m) {
245245
<< dendl;
246246
if (can_write != WriteStatus::REPLACING && !write_in_progress) {
247247
write_in_progress = true;
248-
249-
/* unlock the mutex now because dispatch_event_external() may
250-
block waiting for another mutex */
251-
l.unlock();
252-
253248
connection->center->dispatch_event_external(connection->write_handler);
254249
}
255250
}
@@ -275,14 +270,9 @@ void ProtocolV1::prepare_send_message(uint64_t features, Message *m,
275270

276271
void ProtocolV1::send_keepalive() {
277272
ldout(cct, 10) << __func__ << dendl;
278-
std::unique_lock l{connection->write_lock};
273+
std::lock_guard<std::mutex> l(connection->write_lock);
279274
if (can_write != WriteStatus::CLOSED) {
280275
keepalive = true;
281-
282-
/* unlock the mutex now because dispatch_event_external() may
283-
block waiting for another mutex */
284-
l.unlock();
285-
286276
connection->center->dispatch_event_external(connection->write_handler);
287277
}
288278
}

src/msg/async/ProtocolV2.cc

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ void ProtocolV2::send_message(Message *m) {
440440
is_prepared = false;
441441
}
442442

443-
std::unique_lock l{connection->write_lock};
443+
std::lock_guard<std::mutex> l(connection->write_lock);
444444
// "features" changes will change the payload encoding
445445
if (can_fast_prepare && (!can_write || connection->get_features() != f)) {
446446
// ensure the correctness of message encoding
@@ -464,26 +464,16 @@ void ProtocolV2::send_message(Message *m) {
464464
<< dendl;
465465
if (((!replacing && can_write) || state == STANDBY) && !write_in_progress) {
466466
write_in_progress = true;
467-
468-
/* unlock the mutex now because dispatch_event_external() may
469-
block waiting for another mutex */
470-
l.unlock();
471-
472467
connection->center->dispatch_event_external(connection->write_handler);
473468
}
474469
}
475470
}
476471

477472
void ProtocolV2::send_keepalive() {
478473
ldout(cct, 10) << __func__ << dendl;
479-
std::unique_lock l{connection->write_lock};
474+
std::lock_guard<std::mutex> l(connection->write_lock);
480475
if (state != CLOSED) {
481476
keepalive = true;
482-
483-
/* unlock the mutex now because dispatch_event_external() may
484-
block waiting for another mutex */
485-
l.unlock();
486-
487477
connection->center->dispatch_event_external(connection->write_handler);
488478
}
489479
}

0 commit comments

Comments
 (0)