want_monmap(true),
want_keys(0), global_id(0),
authenticate_err(0),
+ session_established_context(NULL),
auth(NULL),
keyring(NULL),
rotating_secrets(NULL),
MonClient::~MonClient()
{
delete auth_supported;
+ delete session_established_context;
delete auth;
delete keyring;
delete rotating_secrets;
void MonClient::handle_auth(MAuthReply *m)
{
+ Context *cb = NULL;
bufferlist::iterator p = m->result_bl.begin();
if (state == MC_STATE_NEGOTIATING) {
if (!auth || (int)m->protocol != auth->get_protocol()) {
log_client->reset_session();
send_log();
}
+ if (session_established_context) {
+ cb = session_established_context;
+ session_established_context = NULL;
+ }
}
_check_auth_tickets();
}
auth_cond.SignalAll();
+ if (cb) {
+ monc_lock.Unlock();
+ cb->complete(0);
+ monc_lock.Lock();
+ }
}
int authenticate_err;
list<Message*> waiting_for_session;
+ Context *session_established_context;
string _pick_random_mon();
void _finish_hunting();
Mutex::Locker l(monc_lock);
_send_mon_message(m);
}
- void reopen_session() {
+ /**
+ * If you specify a callback, you should not call
+ * reopen_session() again until it has been triggered. The MonClient
+ * will behave, but the first callback could be triggered after
+ * the session has been killed and the MonClient has started trying
+ * to reconnect to another monitor.
+ */
+ void reopen_session(Context *cb=NULL) {
Mutex::Locker l(monc_lock);
+ if (cb) {
+ delete session_established_context;
+ session_established_context = cb;
+ }
_reopen_session();
}