mirror of https://github.com/BOINC/boinc.git
*** empty log message ***
svn path=/trunk/boinc/; revision=8937
This commit is contained in:
parent
42c9d23238
commit
b476e75f37
|
@ -13912,3 +13912,12 @@ David 25 Nov 2005
|
|||
client_state.C
|
||||
client_types.h
|
||||
gui_rpc_server_ops.C
|
||||
|
||||
Rom 25 Nov 2005
|
||||
- Bug Fix: Curses to Windows allowing more than one application
|
||||
to open up a listening socket to a port. Sometimes the
|
||||
manager was being directed to another application instead of
|
||||
BOINC.
|
||||
|
||||
client/
|
||||
gui_rpc_server.C, .h
|
||||
|
|
|
@ -133,6 +133,30 @@ int GUI_RPC_CONN_SET::get_allowed_hosts() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool GUI_RPC_CONN_SET::is_primary_port_available() {
|
||||
int retval;
|
||||
int sock;
|
||||
sockaddr_in addr;
|
||||
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
addr.sin_family = AF_INET;
|
||||
addr.sin_port = htons(GUI_RPC_PORT);
|
||||
|
||||
if (gstate.allow_remote_gui_rpc || allowed_remote_ip_addresses.size() > 0) {
|
||||
addr.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
} else {
|
||||
addr.sin_addr.s_addr = inet_addr("127.0.0.1");
|
||||
}
|
||||
|
||||
boinc_socket(sock);
|
||||
retval = connect(sock, (const sockaddr*)(&addr), sizeof(addr));
|
||||
boinc_close_socket(sock);
|
||||
if (retval) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int GUI_RPC_CONN_SET::insert(GUI_RPC_CONN* p) {
|
||||
gui_rpcs.push_back(p);
|
||||
return 0;
|
||||
|
@ -154,7 +178,18 @@ int GUI_RPC_CONN_SET::init() {
|
|||
}
|
||||
|
||||
addr.sin_family = AF_INET;
|
||||
|
||||
// On Windows our primary listening socket might be in use and Windows will
|
||||
// still allow us to open up a listening socket on it. To avoid possible
|
||||
// connection errors with the manager we'll attempt to connect to the port
|
||||
// first to see if anybody is listening, if so we'll use the alternate port
|
||||
// instead.
|
||||
if (is_primary_port_available()) {
|
||||
addr.sin_port = htons(GUI_RPC_PORT);
|
||||
} else {
|
||||
addr.sin_port = htons(GUI_RPC_PORT_ALT);
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
addr.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
#else
|
||||
|
@ -172,7 +207,6 @@ int GUI_RPC_CONN_SET::init() {
|
|||
|
||||
retval = bind(lsock, (const sockaddr*)(&addr), (boinc_socklen_t)sizeof(addr));
|
||||
if (retval) {
|
||||
msg_printf(NULL, MSG_INFO, "Primary listening port already in use; using alternate listening port\n");
|
||||
addr.sin_port = htons(GUI_RPC_PORT_ALT);
|
||||
retval = bind(lsock, (const sockaddr*)(&addr), (boinc_socklen_t)sizeof(addr));
|
||||
if (retval) {
|
||||
|
@ -182,6 +216,11 @@ int GUI_RPC_CONN_SET::init() {
|
|||
return ERR_BIND;
|
||||
}
|
||||
}
|
||||
|
||||
if (addr.sin_port == htons(GUI_RPC_PORT_ALT)) {
|
||||
msg_printf(NULL, MSG_INFO, "Primary listening port was already in use; using alternate listening port\n");
|
||||
}
|
||||
|
||||
retval = listen(lsock, 999);
|
||||
if (retval) {
|
||||
msg_printf(NULL, MSG_ERROR, "GUI RPC listen failed: %d\n", retval);
|
||||
|
|
|
@ -45,6 +45,7 @@ class GUI_RPC_CONN_SET {
|
|||
|
||||
int get_allowed_hosts();
|
||||
int get_password();
|
||||
bool is_primary_port_available();
|
||||
int insert(GUI_RPC_CONN*);
|
||||
public:
|
||||
GUI_RPC_CONN_SET();
|
||||
|
|
Loading…
Reference in New Issue