From 18d8b5dd6c0a0cc0976bd0d68d2703b282f626e8 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 23 Dec 2003 19:21:52 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=2821 --- checkin_notes | 19 +++++++++++++++++++ db/boinc_db.C | 8 ++++++-- db/boinc_db.h | 1 + db/schema.sql | 1 + sched/handle_request.C | 23 ++++++++++++++++++++--- sched/start | 6 +++--- 6 files changed, 50 insertions(+), 8 deletions(-) diff --git a/checkin_notes b/checkin_notes index 96ea607912..7b74455ceb 100755 --- a/checkin_notes +++ b/checkin_notes @@ -8638,3 +8638,22 @@ David 21 Dec 2003 profile_search_action.php user.inc user_search_action.php (new) + +David 23 Dec 2003 + - add mechanism to prevent server spamming + (i.e. frequence requests for work from a single host). + The mechanism: if the last RPC was within 15 minutes, + don't send any work. + - add result.exit_status field to DB + Currently this is populated by the server, + if there's a element in the reply's stderr_out. + There may be a better way to do this. + TODO: display this field in the web GUI + - use SIGHUP instead of SIGINT to stop daemon processes + + db/ + boinc_db.C,h + schema.sql + sched/ + handle_request.C + start diff --git a/db/boinc_db.C b/db/boinc_db.C index 983fcd3223..a1f4f9fdc6 100644 --- a/db/boinc_db.C +++ b/db/boinc_db.C @@ -17,6 +17,9 @@ // Contributor(s): // // $Log$ +// Revision 1.29 2003/12/23 19:21:51 boincadm +// *** empty log message *** +// // Revision 1.28 2003/12/18 00:22:23 boincadm // *** empty log message *** // @@ -488,7 +491,7 @@ void DB_RESULT::db_print(char* buf){ "xml_doc_in='%s', xml_doc_out='%s', stderr_out='%s', " "batch=%d, file_delete_state=%d, validate_state=%d, " "claimed_credit=%.15e, granted_credit=%.15e, opaque=%f, random=%d, " - "client_version_num=%d, appid=%d", + "client_version_num=%d, appid=%d, exit_status=%d", id, create_time, workunitid, server_state, outcome, client_state, hostid, userid, @@ -497,7 +500,7 @@ void DB_RESULT::db_print(char* buf){ xml_doc_in, xml_doc_out, stderr_out, batch, file_delete_state, validate_state, claimed_credit, granted_credit, opaque, random, - client_version_num, appid + client_version_num, appid, exit_status ); unescape_single_quotes(xml_doc_out); unescape_single_quotes(stderr_out); @@ -531,6 +534,7 @@ void DB_RESULT::db_parse(MYSQL_ROW &r) { random = atoi(r[i++]); client_version_num = atoi(r[i++]); appid = atoi(r[i++]); + exit_status = atoi(r[i++]); } int DB_RESULT::insert() { diff --git a/db/boinc_db.h b/db/boinc_db.h index 796bb359f9..3c491e6e6d 100755 --- a/db/boinc_db.h +++ b/db/boinc_db.h @@ -407,6 +407,7 @@ struct RESULT { int random; // determines send order int client_version_num; int appid; // copy of WU's appid + int exit_status; // application exit status, if any // the following not used in the DB char wu_name[256]; diff --git a/db/schema.sql b/db/schema.sql index 399ec8a57f..b41ff9c711 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -218,6 +218,7 @@ create table result ( random integer not null, client_version_num integer not null, appid integer not null, + exit_status integer not null, primary key (id) ); diff --git a/sched/handle_request.C b/sched/handle_request.C index 24aac1a4db..1e6b9e1340 100644 --- a/sched/handle_request.C +++ b/sched/handle_request.C @@ -44,6 +44,7 @@ using namespace std; const int MIN_SECONDS_TO_SEND = 0; const int MAX_SECONDS_TO_SEND = (28*SECONDS_PER_DAY); const int MAX_WUS_TO_SEND = 10; +const int MIN_SENDWORK_INTERVAL = 15*60; const double COBBLESTONE_FACTOR = 300.0; @@ -335,7 +336,6 @@ int authenticate_user(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { goto new_host; } reply.host.rpc_seqno = sreq.rpc_seqno; - reply.host.rpc_time = time(0); } else { // here no hostid was given; we'll have to create a new host record // @@ -368,7 +368,6 @@ new_host: host.create_time = time(0); host.userid = reply.user.id; host.rpc_seqno = 0; - host.rpc_time = time(0); strcpy(host.venue, reply.user.venue); retval = host.insert(); if (retval) { @@ -559,6 +558,11 @@ int handle_results( } } + // look for exit status in stderr_out + // TODO: return separately + // + parse_int(result.stderr_out, "", result.exit_status); + // update the result record in DB // result.hostid = reply.host.id; @@ -993,6 +997,7 @@ void process_request( ) { PLATFORM* platform; int retval; + double last_rpc_time; // if different major version of BOINC, just send a message // @@ -1001,6 +1006,8 @@ void process_request( retval = authenticate_user(sreq, reply); if (retval) return; + last_rpc_time = reply.host.rpc_time; + reply.host.rpc_time = time(0); retval = update_host_record(sreq, reply.host); // look up the client's platform in the DB @@ -1028,7 +1035,17 @@ void process_request( handle_results(sreq, reply, reply.host); - send_work(sreq, reply, *platform, ss); + // if last RPC was within MIN_SENDWORK_INTERVAL, don't send work + // + double diff = dtime() - last_rpc_time; + if (diff < MIN_SENDWORK_INTERVAL) { + log_messages.printf( + SchedMessages::NORMAL, + "Not sending work - last RPC too recent: %f\n", diff + ); + } else { + send_work(sreq, reply, *platform, ss); + } send_code_sign_key(sreq, reply, code_sign_key); } diff --git a/sched/start b/sched/start index 87d00d1e4c..083015d747 100755 --- a/sched/start +++ b/sched/start @@ -68,8 +68,8 @@ See "start --help" for options. Daemons: These are continuously-running programs. -The process ID is recorded in the -directory and the process is sent a SIGINT in a DISABLE operation. +The process ID is recorded in the directory +and the process is sent a SIGHUP in a DISABLE operation. Both tasks and daemons can run on a different host (specified by ). The default is the project's main host, @@ -433,7 +433,7 @@ def run_tasks(): def stop_daemon(pid): '''returns 1 if something stopped, else 0''' try: - os.kill(pid, signal.SIGINT) + os.kill(pid, signal.SIGHUP) except OSError, e: if e.errno != 3: print >>sys.stderr, "Warning: couldn't kill pid %d:"%pid, e