Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
maiconkist committed Apr 3, 2019
1 parent 49bfb22 commit 718ec7f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion include/hydra/hydra_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class hydra_client
int request_tx_resources(rx_configuration &tx_conf);

/* Check whether the hypervisor is alive */
std::string check_connection();
std::string check_connection(size_t max_tries = 10);

/* Query the available resources */
std::string query_resources();
Expand Down
15 changes: 11 additions & 4 deletions lib/hydra_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ int
hydra_client::discover_server(std::string client_ip,
std::string &server_ip)
{
std::cout << "discover_server" << std::endl;;
const int MAX_MSG = 1000;
send_udp(client_ip, client_ip, true, 5001);

Expand Down Expand Up @@ -144,10 +143,18 @@ hydra_client::request_tx_resources(rx_configuration &tx_conf)
}

std::string
hydra_client::check_connection()
hydra_client::check_connection(size_t max_tries)
{
std::cout << "check_connection" << std::endl;
while (discover_server(s_client_host, s_server_host) < 0) sleep(1);
size_t tries = 0;
size_t status;

while ( (status = discover_server(s_client_host, s_server_host)) < 0 &&
(tries++ < max_tries))
{
if (status < 0 && tries >= max_tries) return std::string("");

sleep(1);
}

// Set message type
std::string message = "{\"xvl_syn\":\"\"}";
Expand Down

0 comments on commit 718ec7f

Please sign in to comment.