The monclient will do the timing out.
AuthClientProtocolHandler::AuthClientProtocolHandler(AuthClientHandler *client) :
- msg(NULL), got_response(false), got_timeout(false),
- timeout_event(NULL), lock("AuthClientProtocolHandler")
+ msg(NULL), got_response(false), lock("AuthClientProtocolHandler")
{
dout(0) << "AuthClientProtocolHandler::AuthClientProtocolHandler" << dendl;
this->client = client;
return ret;
}
-int AuthClientProtocolHandler::do_async_request(double timeout)
+int AuthClientProtocolHandler::do_async_request()
{
got_response = false;
client->client->send_auth_message(msg);
-#if 0
- // schedule timeout?
- assert(timeout_event == 0);
- timeout_event = new C_OpTimeout(this, timeout);
- client->timer.add_event_after(timeout, timeout_event);
-
-
- dout(0) << "got_response=" << got_response << " got_timeout=" << got_timeout << dendl;
-
- // finish.
- if (timeout_event) {
- client->timer.cancel_event(timeout_event);
- timeout_event = NULL;
- }
-#endif
-
return 0;
}
-void AuthClientProtocolHandler::_request_timeout(double timeout)
-{
- dout(10) << "_request_timeout" << dendl;
- timeout_event = NULL;
- if (!got_response) {
- got_timeout = 1;
- cond.Signal();
- }
- status = -ETIMEDOUT;
-}
-
int AuthClientProtocolHandler::handle_response(int ret, bufferlist::iterator& iter)
{
if (!client) {
return handler->handle_response(ret, iter);
}
-int AuthClientHandler::send_session_request(AuthClient *client, AuthClientProtocolHandler *handler, double timeout)
+int AuthClientHandler::send_session_request(AuthClient *client, AuthClientProtocolHandler *handler)
{
Mutex::Locker l(lock);
this->client = client;
if (err < 0)
return err;
- err = handler->do_async_request(timeout);
+ err = handler->do_async_request();
dout(0) << "handler.do_async_request returned " << err << dendl;
return err;
class AuthClientHandler;
class AuthClientProtocolHandler {
- class C_OpTimeout : public Context {
- protected:
- AuthClientProtocolHandler *client;
- double timeout;
- public:
- C_OpTimeout(AuthClientProtocolHandler *handler, double to) :
- client(handler), timeout(to) {
- }
- void finish(int r) {
- if (r >= 0) client->_request_timeout(timeout);
- }
- };
-
protected:
AuthClientHandler *client;
Message *msg;
bool got_response;
- bool got_timeout;
- Context *timeout_event;
uint32_t id;
Mutex lock;
AuthAuthorizer authorizer;
virtual Message *_get_new_msg() = 0;
virtual bufferlist& _get_msg_bl(Message *m) = 0;
- void _request_timeout(double timeout);
public:
AuthClientProtocolHandler(AuthClientHandler *ch);
virtual ~AuthClientProtocolHandler();
_reset();
}
- int do_async_request(double timeout);
+ int do_async_request();
};
class AuthClientAuthenticateHandler : public AuthClientProtocolHandler {
response_state = 0;
cephx_request_state = 0;
cephx_response_state = 0;
- timeout_event = NULL;
}
bool request_pending();
AuthClient *client;
- Message *build_authenticate_request();
-
-
- SafeTimer timer;
-
uint32_t max_proto_handlers;
map<uint32_t, AuthClientProtocolHandler *> handlers_map;
AuthClientProtocolHandler *_get_proto_handler(uint32_t id);
uint32_t _add_proto_handler(AuthClientProtocolHandler *handler);
- void _authenticate_request_timeout(double timeout);
- int _do_authenticate_request(double timeout);
public:
EntityName name;
entity_addr_t addr;
AuthTicketManager tickets;
AuthClientHandler() : lock("AuthClientHandler::lock"),
- client(NULL), timer(lock), max_proto_handlers(0) { }
+ client(NULL), max_proto_handlers(0) { }
void init(EntityName& n) { name = n; }
void set_want_keys(__u32 keys) {
int handle_response(int trans_id, Message *response);
- int send_session_request(AuthClient *client, AuthClientProtocolHandler *handler, double timeout);
+ int send_session_request(AuthClient *client, AuthClientProtocolHandler *handler);
void tick();
int build_authorizer(uint32_t service_id, AuthAuthorizer& authorizer);
delete m;
if (ret == -EAGAIN) {
- auth.send_session_request(this, &auth_handler, 30.0);
+ auth.send_session_request(this, &auth_handler);
} else {
switch (state) {
case MC_STATE_AUTHENTICATING:
{
dout(0) << "done authenticating" << dendl;
state = MC_STATE_AUTHENTICATED;
- auth.send_session_request(this, &authorize_handler, 30.0);
+ auth.send_session_request(this, &authorize_handler);
}
break;
case MC_STATE_AUTHENTICATED:
state = MC_STATE_AUTHENTICATING;
auth_handler.reset();
authorize_handler.reset();
- auth.send_session_request(this, &auth_handler, 30.0);
+ auth.send_session_request(this, &auth_handler);
}
if (g_keyring.need_rotating_secrets())