Changeset - 21a6955ca049
[Not reviewed]
0 2 0
Jan Kaluza - 9 years ago 2016-01-26 19:44:33
jkaluza@redhat.com
Increase the timeout for set_oauth2_code to 10 seconds
2 files changed with 4 insertions and 4 deletions:
0 comments (0 inline, 0 general)
spectrum_manager/src/server.cpp
Show inline comments
 
@@ -277,7 +277,7 @@ void Server::print_html(struct mg_connection *conn, struct http_message *hm, con
 
			(int) html.size() + m_header.size() + m_footer.size(), m_header.c_str(), html.c_str(), m_footer.c_str());
 
}
 

	
 
std::string Server::send_command(const std::string &jid, const std::string &cmd) {
 
std::string Server::send_command(const std::string &jid, const std::string &cmd, int timeout) {
 
	Swift::SimpleEventLoop eventLoop;
 
	Swift::BoostNetworkFactories networkFactories(&eventLoop);
 

	
 
@@ -288,7 +288,7 @@ std::string Server::send_command(const std::string &jid, const std::string &cmd)
 
	gettimeofday(&td_end, NULL);
 

	
 
	time_t started = time(NULL);
 
	while(get_response().empty() && td_end.tv_sec - td_start.tv_sec < 1) {
 
	while(get_response().empty() && td_end.tv_sec - td_start.tv_sec < timeout) {
 
		gettimeofday(&td_end, NULL);
 
		eventLoop.runOnce();
 
	}
 
@@ -396,7 +396,7 @@ void Server::serve_oauth2(struct mg_connection *conn, struct http_message *hm) {
 
	std::string code = get_http_var(hm, "code");
 
	std::string state = get_http_var(hm, "state");
 

	
 
	std::string response = send_command(instance, "set_oauth2_code " + code + " " + state);
 
	std::string response = send_command(instance, "set_oauth2_code " + code + " " + state, 10);
 
	std::cerr << "set_oauth2_code response: '" << response << "'\n";
 
	if (response.find("Registered as ") == 0) {
 
		std::vector<std::string> args;
spectrum_manager/src/server.h
Show inline comments
 
@@ -64,7 +64,7 @@ class Server {
 

	
 
		void redirect_to(struct mg_connection *conn, struct http_message *hm, const char *where);
 

	
 
		std::string send_command(const std::string &jid, const std::string &cmd);
 
		std::string send_command(const std::string &jid, const std::string &cmd, int timeout = 1);
 

	
 
	private:
 
		void serve_logout(struct mg_connection *conn, struct http_message *hm);
0 comments (0 inline, 0 general)