diff options
author | Sage Weil <sage@inktank.com> | 2012-06-05 16:15:43 -0700 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2012-06-05 16:39:16 -0700 |
commit | 85fee0403dd0610a30e5ad9eec0b7d3ac02a40aa (patch) | |
tree | 50309c3ed61c3199b6ad057da850e08ff8cef417 /src/common | |
parent | b6059ccc2f69139dc2d86bbbf226180b2a52a7a9 (diff) | |
download | ceph-85fee0403dd0610a30e5ad9eec0b7d3ac02a40aa.tar.gz |
logclient: fix crashes, fix which entries are sent
I was seeing crashes when the monitor tried to send log entries.
* Send log entries that haven't already been sent.
* Don't try to be tricky with the deque; i'm paranoid about the stability
of the iterator.
* various asserts
* better variable names
Signed-off-by: Sage Weil <sage@inktank.com>
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/LogClient.cc | 26 | ||||
-rw-r--r-- | src/common/LogClient.h | 3 |
2 files changed, 16 insertions, 13 deletions
diff --git a/src/common/LogClient.cc b/src/common/LogClient.cc index cb0e603c4d2..e22283cc62a 100644 --- a/src/common/LogClient.cc +++ b/src/common/LogClient.cc @@ -159,24 +159,30 @@ Message *LogClient::_get_mon_log_message() return NULL; // limit entries per message - unsigned num = last_log - last_log_sent; - unsigned i; + unsigned num_unsent = last_log - last_log_sent; + unsigned num_send; if (cct->_conf->mon_client_max_log_entries_per_message > 0) - i = MIN(num, cct->_conf->mon_client_max_log_entries_per_message); + num_send = MIN(num_unsent, cct->_conf->mon_client_max_log_entries_per_message); else - i = num; + num_send = num_unsent; ldout(cct,10) << " log_queue is " << log_queue.size() << " last_log " << last_log << " sent " << last_log_sent - << " num " << num << " sending " << i << dendl; - std::deque<LogEntry> o(i); + << " num " << log_queue.size() + << " unsent " << num_unsent + << " sending " << num_send << dendl; + assert(num_unsent <= log_queue.size()); std::deque<LogEntry>::iterator p = log_queue.begin(); - std::deque<LogEntry>::iterator q = o.begin(); - while (q != o.end()) { - *q = *p; + std::deque<LogEntry> o; + while (p->seq < last_log_sent) { + p++; + assert(p != log_queue.end()); + } + while (num_send--) { + assert(p != log_queue.end()); + o.push_back(*p); last_log_sent = p->seq; ldout(cct,10) << " will send " << *p << dendl; p++; - q++; } MLog *log = new MLog(monmap->get_fsid()); diff --git a/src/common/LogClient.h b/src/common/LogClient.h index 6a2a037ca55..8fa7bd14ce6 100644 --- a/src/common/LogClient.h +++ b/src/common/LogClient.h @@ -100,9 +100,6 @@ private: void do_log(clog_type type, std::stringstream& ss); void do_log(clog_type type, const std::string& s); Message *_get_mon_log_message(); - void ms_handle_connect(Connection *con) {} - bool ms_handle_reset(Connection *con) { return false; } - void ms_handle_remote_reset(Connection *con) {} CephContext *cct; Messenger *messenger; |