break;
case CEPH_MSG_AUTH_REPLY:
- op_handler = &auth_handler;
+ op_handler = cur_auth_handler;
break;
default:
int MonClient::authorize(double mount_timeout)
{
- int ret = auth_handler.do_op(mount_timeout);
+ Mutex::Locker l(auth_lock);
+ int ret;
- dout(0) << "auth ret=" << ret << dendl;
+ do {
+ MonClientAuthHandler h(this);
+
+ cur_auth_handler = &h;
+
+ int err = h.do_op(mount_timeout);
+ if (err < 0)
+ return err;
+
+ ret = h.get_result();
+ dout(0) << "auth ret=" << ret << dendl;
+ } while (ret == -EAGAIN);
return ret;
}
Mutex::Locker lock(op_lock);
if (done) {
+ dout(5) << "op already done" << dendl;;
dout(5) << "op already done" << dendl;;
return 0;
}
(!itsme && !done)) { // non-doers wait a little longer
cond.Wait(op_lock);
}
+ num_waiters--;
if (!itsme) {
dout(5) << "additional returning" << dendl;
cond.SignalAll(); // wake up non-doers
+
return 0;
}
if (!msg)
return NULL;
bufferlist& bl = msg->get_auth_payload();
-#if 0
-
- EntityName name;
- entity_addr_t my_addr;
- build_authenticate_request(name, my_addr, bl);
-#endif
- CephXEnvRequest1 req;
- req.init();
-
- ::encode(req, bl);
+ if (client->auth_client_handler.generate_request(bl) < 0) {
+ delete msg;
+ return NULL;
+ }
return msg;
}
void MonClient::MonClientAuthHandler::handle_response(Message *response)
{
+ MAuthReply* m = (MAuthReply *)response;
Mutex::Locker lock(op_lock);
+
+ dout(0) << "ret=" << m->result << dendl;
+
+ last_result = (int)m->result;
+
+ if (m->result == 0 || m->result == -EAGAIN) {
+ client->auth_client_handler.handle_response(m->result_bl);
+ }
+
cond.Signal();
return; /* FIXME */
}
+
bufferlist tgt;
Mutex monc_lock;
+ Mutex auth_lock;
bool mounted;
int mounters;
bool unmounting;
class MonClientAuthHandler : public MonClientOpHandler {
bool has_data;
+ int last_result;
public:
- MonClientAuthHandler(MonClient *c) : MonClientOpHandler(c) {}
+ MonClientAuthHandler(MonClient *c) : MonClientOpHandler(c) {
+ last_result = 0;
+ }
~MonClientAuthHandler() {}
Message *build_request();
void handle_response(Message *response);
- bool got_response() { return client->tgt.length() != 0; }
+ bool got_response() { return !client->auth_client_handler.request_pending(); }
+ int get_result() { return last_result; }
};
MonClientMountHandler mount_handler;
MonClientUnmountHandler unmount_handler;
- MonClientAuthHandler auth_handler;
+
+ MonClientAuthHandler *cur_auth_handler;
void _try_mount(double timeout);
void _mount_timeout(double timeout);
public:
MonClient() : messenger(NULL),
monc_lock("MonClient::monc_lock"),
+ auth_lock("MonClient::auth_lock"),
mount_handler(this),
- unmount_handler(this),
- auth_handler(this) {
+ unmount_handler(this) {
+ // auth_handler(this) {
mounted = false;
mounters = 0;
unmounting = false;