Consider this case:
send-thread msg-work
write_event()
r = write_message()
connection->write_lock.lock()
if (.. && !write_in_progress) {
write_in_progress = true;
add external_event
}
connection->write_lock.unlock()
connection->write_lock.lock()
if (r > 0)
break;
} while ();
write_in_progress = false;
For this case, we don't add external_event and in write_event we don't
check out_q whether empty rather than break.
This make msg-work never wake up again.
Fortunately, if write_message() > 0, in AsyncConnection::_try_send will
add an EVENT_WRITEABLE to wake up msg-work. So bug can't occur.
I add comment to descript this and hope get the better method to fix
this.
Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
} else if (r < 0) {
ldout(cct, 1) << __func__ << " send msg failed" << dendl;
break;
- } else if (r > 0)
- break;
+ } else if (r > 0) {
+ // Outbound message in-progress, thread will be re-awoken
+ // when the outbound socket is writeable again
+ break;
+ }
} while (can_write == WriteStatus::CANWRITE);
write_in_progress = false;
connection->write_lock.unlock();
} else if (r < 0) {
ldout(cct, 1) << __func__ << " send msg failed" << dendl;
break;
- } else if (r > 0)
+ } else if (r > 0) {
+ // Outbound message in-progress, thread will be re-awoken
+ // when the outbound socket is writeable again
break;
+ }
} while (can_write);
write_in_progress = false;