*** empty log message ***

svn path=/trunk/boinc/; revision=9025
This commit is contained in:
Rom Walton 2005-12-04 10:57:35 +00:00
parent 40306067cb
commit a241db7128
5 changed files with 68 additions and 4 deletions

View File

@ -14184,3 +14184,13 @@ David 2 Dec 2005
lib/ lib/
shmem.C shmem.C
Rom 4 Dec 2005
- Bug Fix: Verify we are actually talking with a BOINC core client
before declaring a connection successful.
client/
gui_rpc_server_ops.C
lib/
gui_rpc_client.C, .h
gui_rpc_client_ops.C

View File

@ -74,6 +74,12 @@ void GUI_RPC_CONN::handle_auth2(char* buf, MIOFILE& fout) {
auth_needed = false; auth_needed = false;
} }
static void handle_get_client_time(MIOFILE& fout) {
fout.printf("<client_time>\n");
fout.printf("<time>%f</time>\n", dtime());
fout.printf("</client_time>\n");
}
static void handle_get_project_status(MIOFILE& fout) { static void handle_get_project_status(MIOFILE& fout) {
unsigned int i; unsigned int i;
fout.printf("<projects>\n"); fout.printf("<projects>\n");
@ -743,6 +749,8 @@ int GUI_RPC_CONN::handle_rpc() {
MFILE m; MFILE m;
char* p; char* p;
int major_version; int major_version;
int minor_version;
int release;
mf.init_mfile(&m); mf.init_mfile(&m);
SCOPE_MSG_LOG scope_messages(log_messages, CLIENT_MSG_LOG::DEBUG_GUIRPC); SCOPE_MSG_LOG scope_messages(log_messages, CLIENT_MSG_LOG::DEBUG_GUIRPC);
@ -764,6 +772,8 @@ int GUI_RPC_CONN::handle_rpc() {
// get client version. not used for now // get client version. not used for now
// //
parse_int(request_msg, "<major_version>", major_version); parse_int(request_msg, "<major_version>", major_version);
parse_int(request_msg, "<minor_version>", minor_version);
parse_int(request_msg, "<release>", release);
mf.printf( mf.printf(
"<boinc_gui_rpc_reply>\n" "<boinc_gui_rpc_reply>\n"
@ -784,6 +794,8 @@ int GUI_RPC_CONN::handle_rpc() {
// operations that require authentication for non-local clients start here // operations that require authentication for non-local clients start here
} else if (match_tag(request_msg, "<get_client_time")) {
handle_get_client_time(mf);
} else if (match_tag(request_msg, "<get_state")) { } else if (match_tag(request_msg, "<get_state")) {
gstate.write_state_gui(mf); gstate.write_state_gui(mf);
} else if (match_tag(request_msg, "<get_results")) { } else if (match_tag(request_msg, "<get_results")) {

View File

@ -52,9 +52,16 @@
using std::string; using std::string;
using std::vector; using std::vector;
RPC_CLIENT::RPC_CLIENT() {} RPC_CLIENT::RPC_CLIENT() {
client_major_version = 0;
client_minor_version = 0;
client_release = 0;
}
RPC_CLIENT::~RPC_CLIENT() { RPC_CLIENT::~RPC_CLIENT() {
client_major_version = 0;
client_minor_version = 0;
client_release = 0;
close(); close();
} }
@ -70,6 +77,7 @@ void RPC_CLIENT::close() {
} }
int RPC_CLIENT::init(const char* host) { int RPC_CLIENT::init(const char* host) {
double client_time = 0.0;
int retval; int retval;
memset(&addr, 0, sizeof(addr)); memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET; addr.sin_family = AF_INET;
@ -107,6 +115,15 @@ int RPC_CLIENT::init(const char* host) {
return ERR_CONNECT; return ERR_CONNECT;
} }
} }
// Are we really talking to a BOINC core client.
if (get_client_time(client_time)) {
return ERR_RETRY;
}
if ((client_time == 0.0) && ((0 == client_major_version) && (0 == client_minor_version) && (0 == client_release))) {
return ERR_RETRY;
}
return 0; return 0;
} }
@ -151,6 +168,7 @@ int RPC_CLIENT::init_asynch(const char* host, double _timeout, bool _retry) {
int RPC_CLIENT::init_poll() { int RPC_CLIENT::init_poll() {
fd_set read_fds, write_fds, error_fds; fd_set read_fds, write_fds, error_fds;
struct timeval tv; struct timeval tv;
double client_time = 0.0;
int retval; int retval;
FD_ZERO(&read_fds); FD_ZERO(&read_fds);
@ -177,6 +195,12 @@ int RPC_CLIENT::init_poll() {
BOINCTRACE("asynch error: %d\n", retval); BOINCTRACE("asynch error: %d\n", retval);
return retval; return retval;
} }
if (get_client_time(client_time)) {
return ERR_RETRY;
}
if ((client_time == 0.0) && ((0 == client_major_version) && (0 == client_minor_version) && (0 == client_release))) {
return ERR_RETRY;
}
return 0; return 0;
} else { } else {
BOINCTRACE("init_poll: get_socket_error(): %d\n", retval); BOINCTRACE("init_poll: get_socket_error(): %d\n", retval);

View File

@ -520,6 +520,7 @@ public:
int init_poll(); int init_poll();
void close(); void close();
int authorize(const char* passwd); int authorize(const char* passwd);
int get_client_time(double& client_time);
int get_state(CC_STATE&); int get_state(CC_STATE&);
int get_results(RESULTS&); int get_results(RESULTS&);
int get_file_transfers(FILE_TRANSFERS&); int get_file_transfers(FILE_TRANSFERS&);

View File

@ -886,6 +886,26 @@ void LOOKUP_WEBSITE::clear() {
/////////// END OF PARSING FUNCTIONS. RPCS START HERE //////////////// /////////// END OF PARSING FUNCTIONS. RPCS START HERE ////////////////
int RPC_CLIENT::get_client_time(double& client_time) {
char buf[256];
RPC rpc(this);
int retval;
client_time = 0;
retval = rpc.do_rpc("<get_client_time/>\n");
if (retval) return retval;
while (rpc.fin.fgets(buf, 256)) {
if (match_tag(buf, "</client_time>")) break;
else if (parse_int(buf, "<client_major_version>", client_major_version)) continue;
else if (parse_int(buf, "<client_minor_version>", client_minor_version)) continue;
else if (parse_int(buf, "<client_release>", client_release)) continue;
else if (parse_double(buf, "<time>", client_time)) continue;
}
return 0;
}
int RPC_CLIENT::get_state(CC_STATE& state) { int RPC_CLIENT::get_state(CC_STATE& state) {
char buf[256]; char buf[256];
PROJECT* project = NULL; PROJECT* project = NULL;
@ -893,9 +913,6 @@ int RPC_CLIENT::get_state(CC_STATE& state) {
int retval; int retval;
state.clear(); state.clear();
client_major_version = 0;
client_minor_version = 0;
client_release = 0;
retval = rpc.do_rpc("<get_state/>\n"); retval = rpc.do_rpc("<get_state/>\n");
if (retval) return retval; if (retval) return retval;