From 07395c8f471818cc75ec4c28f15830a2233378f7 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Mon, 23 Apr 2007 20:35:55 +0000 Subject: [PATCH] svn path=/trunk/boinc/; revision=12454 --- checkin_notes | 7 +++++++ client/gui_rpc_server.C | 38 +++++++++++++++----------------------- client/gui_rpc_server.h | 3 ++- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/checkin_notes b/checkin_notes index 2a5b2b87ec..2ad6b7226f 100755 --- a/checkin_notes +++ b/checkin_notes @@ -3928,3 +3928,10 @@ Rom 23 Apr 2007 zlib/ + +David 23 Apr 2007 + - client: fix bug where client is unresponsive if + there are unresolvable names in remote_hosts.cfg file + + client/ + gui_rpc_server.C,h diff --git a/client/gui_rpc_server.C b/client/gui_rpc_server.C index e273586fe7..09d6c4ad46 100644 --- a/client/gui_rpc_server.C +++ b/client/gui_rpc_server.C @@ -126,20 +126,18 @@ int GUI_RPC_CONN_SET::get_password() { return 0; } -// If 'last time', show errors, try all entries, return zero -// Otherwise return nonzero on first failed entry, don't show errors -// -int GUI_RPC_CONN_SET::get_allowed_hosts(bool last_time) { - int ipaddr, retval, overall_retval=0; +int GUI_RPC_CONN_SET::get_allowed_hosts() { + int ipaddr, retval; char buf[256]; allowed_remote_ip_addresses.clear(); + remote_hosts_file_exists = false; - // open file remote_hosts.cfg and read in the - // allowed host list and resolve them to an ip address + // scan remote_hosts.cfg, convert names to IP addresses // FILE* f = fopen(REMOTEHOST_FILE_NAME, "r"); - if (f) { + if (f) { + remote_hosts_file_exists = true; if (log_flags.guirpc_debug) { msg_printf(0, MSG_INFO, "[guirpc_debug] found allowed hosts list" @@ -155,15 +153,10 @@ int GUI_RPC_CONN_SET::get_allowed_hosts(bool last_time) { if (!(buf[0] =='#' || buf[0] == ';') && strlen(buf) > 0 ) { retval = resolve_hostname(buf, ipaddr); if (retval) { - overall_retval = retval; - if (last_time) { - msg_printf(0, MSG_USER_ERROR, - "Can't resolve hostname %s in %s", - buf, REMOTEHOST_FILE_NAME - ); - } else { - break; - } + msg_printf(0, MSG_USER_ERROR, + "Can't resolve hostname %s in %s", + buf, REMOTEHOST_FILE_NAME + ); } else { allowed_remote_ip_addresses.push_back((int)ntohl(ipaddr)); } @@ -171,7 +164,7 @@ int GUI_RPC_CONN_SET::get_allowed_hosts(bool last_time) { } fclose(f); } - return overall_retval; + return 0; } int GUI_RPC_CONN_SET::insert(GUI_RPC_CONN* p) { @@ -189,9 +182,8 @@ int GUI_RPC_CONN_SET::init(bool last_time) { sockaddr_in addr; int retval; - retval = get_allowed_hosts(last_time); - if (retval) return retval; get_password(); + get_allowed_hosts(); retval = boinc_socket(lsock); if (retval) { @@ -215,7 +207,7 @@ int GUI_RPC_CONN_SET::init(bool last_time) { #ifdef __APPLE__ addr.sin_addr.s_addr = htonl(INADDR_ANY); #else - if (gstate.allow_remote_gui_rpc || allowed_remote_ip_addresses.size() > 0) { + if (gstate.allow_remote_gui_rpc || remote_hosts_file_exists) { addr.sin_addr.s_addr = htonl(INADDR_ANY); if (log_flags.guirpc_debug) { msg_printf(NULL, MSG_INFO, "[guirpc_debug] Remote control allowed"); @@ -372,9 +364,9 @@ void GUI_RPC_CONN_SET::got_select(FDSET_GROUP& fg) { allowed = true; is_local = true; } else { - // reread it because IP addresses might have changed + // reread host file because IP addresses might have changed // - get_allowed_hosts(true); + get_allowed_hosts(); allowed = check_allowed_list(peer_ip); } diff --git a/client/gui_rpc_server.h b/client/gui_rpc_server.h index 0edc348727..991a47fcd5 100644 --- a/client/gui_rpc_server.h +++ b/client/gui_rpc_server.h @@ -60,10 +60,11 @@ public: class GUI_RPC_CONN_SET { std::vector gui_rpcs; std::vector allowed_remote_ip_addresses; - int get_allowed_hosts(bool last_time); + int get_allowed_hosts(); int get_password(); int insert(GUI_RPC_CONN*); bool check_allowed_list(int ip_addr); + bool remote_hosts_file_exists; public: int lsock; double time_of_last_rpc_needing_network;