Skip to content

Commit

Permalink
XenServer: when we receive a SESSION_INVALID, automatically log back in
Browse files Browse the repository at this point in the history
It's possible for a session to be expired by the server, due to
inactivity. In this case we should log back in.

This also works around a problem where some other thread appears to be
logging out our session, even though we're still using it (for
event.from)

Signed-off-by: David Scott <dave.scott@citrix.com>
  • Loading branch information
David Scott committed Apr 28, 2014
1 parent 991c0dd commit 9d40f56
Showing 1 changed file with 20 additions and 17 deletions.
Expand Up @@ -451,24 +451,27 @@ protected Map dispatch(String methodcall, Object[] methodparams) throws XmlRpcE
return super.dispatch(methodcall, methodparams);
}

try {
return super.dispatch(methodcall, methodparams);
} catch (Types.SessionInvalid e) {
s_logger.debug("Session is invalid for method: " + methodcall + " due to " + e.toString());
removeConnect(_poolUuid);
throw e;
} catch (XmlRpcClientException e) {
s_logger.debug("XmlRpcClientException for method: " + methodcall + " due to " + e.toString());
removeConnect(_poolUuid);
throw e;
} catch (XmlRpcException e) {
s_logger.debug("XmlRpcException for method: " + methodcall + " due to " + e.toString());
removeConnect(_poolUuid);
throw e;
} catch (Types.HostIsSlave e) {
s_logger.debug("HostIsSlave Exception for method: " + methodcall + " due to " + e.toString());
removeConnect(_poolUuid);
while (true) {
try {
return super.dispatch(methodcall, methodparams);
} catch (Types.SessionInvalid e) {
s_logger.warn("Session is invalid for method: " + methodcall + " logging back in");
// This will reset the session reference cached inside the Connection
Session.loginWithPassword(this, _username, _password.peek(), APIVersion.latest().toString());
continue;
} catch (XmlRpcClientException e) {
s_logger.debug("XmlRpcClientException for method: " + methodcall + " due to " + e.toString());
removeConnect(_poolUuid);
throw e;
} catch (XmlRpcException e) {
s_logger.debug("XmlRpcException for method: " + methodcall + " due to " + e.toString());
removeConnect(_poolUuid);
throw e;
} catch (Types.HostIsSlave e) {
s_logger.debug("HostIsSlave Exception for method: " + methodcall + " due to " + e.toString());
removeConnect(_poolUuid);
throw e;
}
}
}
}
Expand Down

0 comments on commit 9d40f56

Please sign in to comment.