msg/async: fix is_queued() semantics

Before AsyncConnection was split into two classes as part of the
multi-protocol refactor, we only had AsyncConnection::is_queued().
It checked both out_q and outcoming_bl because out_q was part of
AsyncConnection.

out_q is now part of ProtocolV1.  AsyncConnection should no longer be
concerned with out_q, only with outcoming_bl.  Checking whether out_q
is empty in _try_send() is particuarly wrong because if the write is
fininished (i.e. outcoming_bl is empty) but out_q has something in it,
the write callback isn't invoked.

Although probably not strictly necessary, this commit preserves the
semantics of connection->is_queued() in Protocol.cc.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
This commit is contained in:
Ilya Dryomov 2018-10-19 19:34:19 +02:00
parent cb48963385
commit b7a62742fc
2 changed files with 7 additions and 6 deletions

View File

@ -551,7 +551,7 @@ void AsyncConnection::_stop() {
}
bool AsyncConnection::is_queued() const {
return protocol->is_queued() || outcoming_bl.length();
return outcoming_bl.length();
}
void AsyncConnection::shutdown_socket() {

View File

@ -367,7 +367,7 @@ void ProtocolV1::write_event() {
ack_left -= left;
left = ack_left;
r = connection->_try_send(left);
} else if (connection->is_queued()) {
} else if (is_queued()) {
r = connection->_try_send();
}
}
@ -385,8 +385,7 @@ void ProtocolV1::write_event() {
connection->write_lock.unlock();
connection->lock.lock();
connection->write_lock.lock();
if (state == STANDBY && !connection->policy.server &&
connection->is_queued()) {
if (state == STANDBY && !connection->policy.server && is_queued()) {
ldout(cct, 10) << __func__ << " policy.server is false" << dendl;
connection->_connect();
} else if (connection->cs && state != NONE && state != CLOSED &&
@ -405,7 +404,9 @@ void ProtocolV1::write_event() {
}
}
bool ProtocolV1::is_queued() { return !out_q.empty(); }
bool ProtocolV1::is_queued() {
return !out_q.empty() || connection->is_queued();
}
void ProtocolV1::run_continuation(CtPtr continuation) {
CONTINUATION_RUN(continuation);
@ -453,7 +454,7 @@ CtPtr ProtocolV1::ready() {
connection->write_lock.lock();
can_write = WriteStatus::CANWRITE;
if (connection->is_queued()) {
if (is_queued()) {
connection->center->dispatch_event_external(connection->write_handler);
}
connection->write_lock.unlock();