bin_PROGRAMS += csyn
testmsgr_SOURCES = testmsgr.cc msg/SimpleMessenger.cc
-testmsgr_LDADD = libcommon.a
+testmsgr_LDADD = libcommon.a -lcrypto
bin_PROGRAMS += testmsgr
+ test_ioctls_SOURCES = client/test_ioctls.c
+ bin_PROGRAMS += test_ioctls
+
# fuse targets?
if WITH_FUSE
cfuse_SOURCES = cfuse.cc msg/SimpleMessenger.cc client/fuse.cc client/fuse_ll.cc
void MonClient::_send_mon_message(Message *m)
{
- int mon = monmap.pick_mon();
- messenger->send_message(m, monmap.mon_inst[mon]);
+ assert(cur_mon >= 0);
+ messenger->send_message(m, monmap.mon_inst[cur_mon]);
}
+void MonClient::send_message(Message *m)
+{
+ _send_mon_message(m);
+}
+
void MonClient::_pick_new_mon()
{
- int oldmon = monmap.pick_mon();
- messenger->mark_down(monmap.get_inst(oldmon).addr);
- monmap.pick_mon(true);
+ if (cur_mon >= 0)
+ messenger->mark_down(monmap.get_inst(cur_mon).addr);
+ cur_mon = monmap.pick_mon(true);
+ dout(10) << "_pick_new_mon picked mon" << cur_mon << dendl;
}
- void MonClient::ms_handle_reset(const entity_addr_t& peer)
-
+ void MonClient::_reopen_session()
{
- dout(10) << "ms_handle_reset " << peer << dendl;
- if (!hunting) {
- dout(0) << "staring hunt for new mon" << dendl;
- hunting = true;
- _pick_new_mon();
- auth.start_session(this, 30.0);
- if (mounting)
- _send_mount();
+ dout(10) << "_reopen_session" << dendl;
+ _pick_new_mon();
++ auth.start_session(this, 30.0);
+ if (mounting)
+ _send_mount();
+ if (!sub_have.empty())
_renew_subs();
+ if (!mounting && sub_have.empty()) {
+ _send_mon_message(new MMonGetMap);
+ }
+ }
+
+ bool MonClient::ms_handle_reset(Connection *con, const entity_addr_t& peer)
+ {
+ dout(10) << "ms_handle_reset " << peer << dendl;
+ if (hunting)
+ return true;
+
+ dout(0) << "hunting for new mon" << dendl;
+ hunting = true;
+ _reopen_session();
+ return false;
+ }
+
+ void MonClient::_finish_hunting()
+ {
+ if (hunting) {
+ dout(0) << "found mon" << cur_mon << dendl;
+ hunting = false;
}
}
if (hunting) {
dout(0) << "continuing hunt" << dendl;
- // try new monitor
- _pick_new_mon();
- if (mounting)
- _send_mount();
- _renew_subs();
+ auth.start_session(this, 30.0);
+ _reopen_session();
} else {
// just renew as needed
utime_t now = g_clock.now();
messenger->send_keepalive(monmap.mon_inst[oldmon]);
}
+ auth.tick();
+
timer.add_event_after(10.0, new C_Tick(this));
- dout(10) << "tick done" << dendl;
-
}
private:
Messenger *messenger;
++<<<<<<< HEAD:src/mon/MonClient.h
+ bufferlist tgt;
++=======
+ int cur_mon;
+
++>>>>>>> origin/unstable:src/mon/MonClient.h
entity_addr_t my_addr;
Mutex monc_lock;
};
void tick();
+ Context *auth_timeout_event;
+ bool auth_got_timeout;
+ Cond auth_cond;
+
+ class C_AuthRotatingTimeout : public Context {
+ protected:
+ MonClient *client;
+ double timeout;
+ public:
+ C_AuthRotatingTimeout(MonClient *c, double to) :
+ client(c), timeout(to) {
+ }
+ void finish(int r) {
+ if (r >= 0) client->_auth_rotating_timeout(timeout);
+ }
+ };
+
+ void handle_auth_rotating_response(MAuthRotating *m);
+ // monclient
+ bool want_monmap;
+
// mount
private:
client_t clientid;
}
}
-
+ // auth tickets
+public:
+ AuthClientHandler auth;
+ double auth_timeout;
-
+ public:
+ void renew_subs() {
+ Mutex::Locker l(monc_lock);
+ _renew_subs();
+ }
+ void sub_want(nstring what, version_t have) {
+ Mutex::Locker l(monc_lock);
+ _sub_want(what, have);
+ }
+ void sub_want_onetime(nstring what, version_t have) {
+ Mutex::Locker l(monc_lock);
+ _sub_want_onetime(what, have);
+ }
+ void sub_got(nstring what, version_t have) {
+ Mutex::Locker l(monc_lock);
+ _sub_got(what, have);
+ }
+
-
public:
- MonClient() : messenger(NULL),
+ MonClient() : messenger(NULL), cur_mon(-1),
monc_lock("MonClient::monc_lock"),
timer(monc_lock),
hunting(false),