diff --git a/checkin_notes b/checkin_notes index d4426d2789..fd54e9aa37 100644 --- a/checkin_notes +++ b/checkin_notes @@ -3905,3 +3905,12 @@ Rom 28 May 2010 boinc.sln cuda.rules cuda.vcproj + +David 31 May 2010 + - GUI RPC client side: set up a 30 second receive timeout for + socket to client. That way GUI won't hang if client does. + From Fred of BoincTasks + + lib/ + network.cpp + gui_rpc_client.cpp diff --git a/lib/gui_rpc_client.cpp b/lib/gui_rpc_client.cpp index 3664590183..34f5f82760 100644 --- a/lib/gui_rpc_client.cpp +++ b/lib/gui_rpc_client.cpp @@ -96,6 +96,15 @@ int RPC_CLIENT::init(const char* host, int port) { addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); } boinc_socket(sock); + + // set up receive timeout; avoid hang if client doesn't respond + // + struct timeval tv; + tv.tv_sec = 30; + tv.tv_usec = 0; + if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof tv)) { + // not fatal + } retval = connect(sock, (const sockaddr*)(&addr), sizeof(addr)); if (retval) { #ifdef _WIN32 diff --git a/lib/network.cpp b/lib/network.cpp index ad09aec028..ca4287c746 100644 --- a/lib/network.cpp +++ b/lib/network.cpp @@ -90,8 +90,8 @@ const char* socket_error_str() { return "host not found or server failure"; #ifdef NETDB_INTERNAL case NETDB_INTERNAL: - sprintf(buf,"network internal error %d",errno); - return buf; + sprintf(buf,"network internal error %d",errno); + return buf; #endif } sprintf(buf, "error %d", h_errno); @@ -194,7 +194,7 @@ int get_socket_error(int fd) { int WinsockInitialize() { WSADATA wsdata; - return WSAStartup( MAKEWORD( 1, 1 ), &wsdata); + return WSAStartup(MAKEWORD(2, 0), &wsdata); } int WinsockCleanup() {