* LogClient: move reset_session() into get_mon_log_message() and add a
"flush" param to the latter. so it can get_mon_log_message()
atomically. otherwise another call changing the log queue could sneak
in between reset_session() and get_mon_log_message().
* MonClient: add a "flush" param to do_send() so we can reset the
LogClient session once we are connected to a monitor.
Fixes: http://tracker.ceph.com/issues/19427
Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit
5215e291da2b527d85e129eda86043490843178e)
Conflicts:
src/mon/MonClient.cc: handle_auth: replaced 'log_client->reset_session();
send_log();' sequence with newly introduced 'send_log(true);' like
the original patch does
}
}
-void LogClient::reset_session()
-{
- Mutex::Locker l(log_lock);
- last_log_sent = last_log - log_queue.size();
-}
-
-Message *LogClient::get_mon_log_message()
+Message *LogClient::get_mon_log_message(bool flush)
{
Mutex::Locker l(log_lock);
+ if (flush) {
+ // reset session
+ last_log_sent = last_log - log_queue.size();
+ }
return _get_mon_log_message();
}
}
bool handle_log_ack(MLogAck *m);
- void reset_session();
- Message *get_mon_log_message();
+ Message *get_mon_log_message(bool flush);
bool are_pending();
LogChannelRef create_channel() {
return true;
}
-void MonClient::send_log()
+void MonClient::send_log(bool flush)
{
if (log_client) {
- Message *lm = log_client->get_mon_log_message();
+ Message *lm = log_client->get_mon_log_message(flush);
if (lm)
_send_mon_message(lm);
more_log_pending = log_client->are_pending();
_send_mon_message(waiting_for_session.front());
waiting_for_session.pop_front();
}
-
_resend_mon_commands();
- if (log_client) {
- log_client->reset_session();
- send_log();
- }
+ send_log(true);
if (session_established_context) {
cb = session_established_context;
session_established_context = NULL;
LogClient *log_client;
bool more_log_pending;
- void send_log();
+ void send_log(bool flush = false);
AuthMethodList *auth_supported;