Merge branch 'master' of ssh://boinc.berkeley.edu/boinc

This commit is contained in:
Oliver Bock 2013-03-22 10:26:19 +01:00
commit 1fb53e5c9f
11 changed files with 167 additions and 72 deletions

View File

@ -81,7 +81,6 @@ void LOG_FLAGS::show() {
show_flag(buf, cpu_sched_debug, "cpu_sched_debug");
show_flag(buf, cpu_sched_status, "cpu_sched_status");
show_flag(buf, dcf_debug, "dcf_debug");
show_flag(buf, priority_debug, "priority_debug");
show_flag(buf, file_xfer_debug, "file_xfer_debug");
show_flag(buf, gui_rpc_debug, "gui_rpc_debug");
show_flag(buf, heartbeat_debug, "heartbeat_debug");
@ -89,7 +88,9 @@ void LOG_FLAGS::show() {
show_flag(buf, http_xfer_debug, "http_xfer_debug");
show_flag(buf, mem_usage_debug, "mem_usage_debug");
show_flag(buf, network_status_debug, "network_status_debug");
show_flag(buf, notice_debug, "notice_debug");
show_flag(buf, poll_debug, "poll_debug");
show_flag(buf, priority_debug, "priority_debug");
show_flag(buf, proxy_debug, "proxy_debug");
show_flag(buf, rr_simulation, "rr_simulation");
show_flag(buf, sched_op_debug, "sched_op_debug");
@ -101,7 +102,6 @@ void LOG_FLAGS::show() {
show_flag(buf, time_debug, "time_debug");
show_flag(buf, unparsed_xml, "unparsed_xml");
show_flag(buf, work_fetch_debug, "work_fetch_debug");
show_flag(buf, notice_debug, "notice_debug");
if (strlen(buf)) {
msg_printf(NULL, MSG_INFO, "log flags: %s", buf);

View File

@ -133,11 +133,15 @@ CDlgEventLog::~CDlgEventLog() {
bool CDlgEventLog::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
////@begin CDlgEventLog member initialisation
CMainDocument* pDoc = wxGetApp().GetDocument();
wxASSERT(pDoc);
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
m_iPreviousRowCount = 0;
m_iTotalDocCount = 0;
m_iPreviousTotalDocCount = 0;
m_iPreviousFirstMsgSeqNum = 0;
m_iPreviousLastMsgSeqNum = 0;
m_iPreviousFirstMsgSeqNum = pDoc->GetFirstMsgSeqNum();
m_iPreviousLastMsgSeqNum = m_iPreviousFirstMsgSeqNum;
m_iNumDeletedFilteredRows = 0;
m_iTotalDeletedFilterRows = 0;
@ -146,6 +150,7 @@ bool CDlgEventLog::Create( wxWindow* parent, wxWindowID id, const wxString& capt
}
m_iFilteredIndexes.Clear();
m_bProcessingRefreshEvent = false;
m_bWasConnected = false;
m_bEventLogIsOpen = true;
////@end CDlgEventLog member initialisation
@ -227,6 +232,7 @@ bool CDlgEventLog::Create( wxWindow* parent, wxWindowID id, const wxString& capt
SetTextColor();
RestoreState();
OnRefresh();
return true;
}
@ -460,15 +466,11 @@ wxInt32 CDlgEventLog::GetDocCount() {
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
m_iTotalDocCount = pDoc->GetMessageCount();
if (m_iTotalDocCount < m_iPreviousTotalDocCount) {
// Usually due to a disconnect from client
ResetMessageFiltering();
m_iPreviousFirstMsgSeqNum = 0;
m_iPreviousLastMsgSeqNum = 0;
}
numDeletedRows = pDoc->GetFirstMsgSeqNum() - m_iPreviousFirstMsgSeqNum;
if (numDeletedRows < 0) numDeletedRows = 0;
if ((numDeletedRows < 0) || (m_iPreviousFirstMsgSeqNum < 0)) {
numDeletedRows = 0;
}
m_iNumDeletedFilteredRows = 0;
if (s_bIsFiltered) {
@ -522,8 +524,6 @@ wxInt32 CDlgEventLog::GetDocCount() {
}
}
}
m_iPreviousTotalDocCount = m_iTotalDocCount;
return s_bIsFiltered ? m_iFilteredDocCount : m_iTotalDocCount;
}
@ -534,7 +534,6 @@ wxInt32 CDlgEventLog::GetDocCount() {
*/
void CDlgEventLog::OnRefresh() {
bool isConnected;
static bool was_connected = false;
static wxString strLastMachineName = wxEmptyString;
wxString strNewMachineName = wxEmptyString;
CMainDocument* pDoc = wxGetApp().GetDocument();
@ -562,16 +561,16 @@ void CDlgEventLog::OnRefresh() {
pDoc->GetConnectedComputerName(strNewMachineName);
if (strLastMachineName != strNewMachineName) {
strLastMachineName = strNewMachineName;
was_connected = false;
m_bWasConnected = false;
ResetMessageFiltering();
m_iPreviousFirstMsgSeqNum = 0;
m_iPreviousLastMsgSeqNum = 0;
m_iPreviousFirstMsgSeqNum = pDoc->GetFirstMsgSeqNum();
m_iPreviousLastMsgSeqNum = m_iPreviousFirstMsgSeqNum;
}
}
// If connection status changed, adjust color of messages display
if (was_connected != isConnected) {
was_connected = isConnected;
if (m_bWasConnected != isConnected) {
m_bWasConnected = isConnected;
SetTextColor();
// Force a complete update
@ -602,9 +601,11 @@ void CDlgEventLog::OnRefresh() {
}
m_iPreviousRowCount = iRowCount;
m_iPreviousFirstMsgSeqNum = pDoc->GetFirstMsgSeqNum();
m_iPreviousLastMsgSeqNum = pDoc->GetLastMsgSeqNum();
if (m_iTotalDocCount > 0) {
m_iPreviousFirstMsgSeqNum = pDoc->GetFirstMsgSeqNum();
m_iPreviousLastMsgSeqNum = pDoc->GetLastMsgSeqNum();
}
UpdateButtons();
m_bProcessingRefreshEvent = false;

View File

@ -147,7 +147,6 @@ private:
wxArrayInt m_iFilteredIndexes;
wxInt32 m_iTotalDocCount;
wxInt32 m_iFilteredDocCount;
wxInt32 m_iPreviousTotalDocCount;
wxInt32 m_iPreviousFirstMsgSeqNum;
wxInt32 m_iPreviousLastMsgSeqNum;
wxInt32 m_iNumDeletedFilteredRows;
@ -163,7 +162,7 @@ private:
wxListItemAttr* m_pMessageErrorGrayAttr;
bool m_bProcessingRefreshEvent;
bool m_bWasConnected;
bool m_bEventLogIsOpen;
bool SaveState();

View File

@ -69,21 +69,30 @@ class BoincDb extends DbConn {
// 2) check whether the "stop_web" trigger file is present
//
static function get($readonly = false) {
global $generating_xml;
if (!isset(self::$instance)) {
if (web_stopped()) {
show_page("Project down for maintenance",
"Please check back in a few hours."
);
exit;
if ($generating_xml) {
xml_error(-183, "project down for maintenance");
} else {
show_page("Project down for maintenance",
"Please check back in a few hours."
);
exit;
}
}
self::get_aux($readonly);
if (!self::$instance) {
show_page(
"Project is down",
"The project's database server is down.
Please check back in a few hours."
);
exit;
if ($generating_xml) {
xml_error(-138, "the project's database server is down");
} else {
show_page(
"Project is down",
"The project's database server is down.
Please check back in a few hours."
);
exit;
}
}
}
return self::$instance;

View File

@ -44,7 +44,6 @@ if (defined('TIMEZONE')) {
date_default_timezone_set('UTC');
}
$generating_xml = false;
$caching = false;
// if set, we're writing to a file rather than to client
$did_page_head = false;

View File

@ -19,6 +19,8 @@
// minimal set of util functions;
// doesn't pull in translation.inc etc.
$generating_xml = false;
function web_stopped() {
$d = dirname(__FILE__);
return file_exists("$d/../../stop_web");

View File

@ -323,26 +323,41 @@ function query_batch($r) {
//
function query_batch2($r) {
list($user, $user_submit) = authenticate_user($r, null);
$batch = get_batch($r);
if ($batch->user_id != $user->id) xml_error(-1, "not owner");
$wus = BoincWorkunit::enum("batch = $batch->id");
echo "<batch>\n";
foreach ($wus as $wu) {
if ($wu->canonical_resultid) {
$status = "DONE";
} else if ($wu->error_mask) {
$status = "ERROR";
} else {
$status = "IN_PROGRESS";
$batch_names = $r->batch_name;
$batches = array();
foreach ($batch_names as $b) {
$batch_name = (string)$b;
$batch_name = BoincDb::escape_string($batch_name);
$batch = BoincBatch::lookup_name($batch_name);
if (!$batch) {
xml_error(-1, "no batch named $batch_name");
}
echo
if ($batch->user_id != $user->id) {
xml_error(-1, "not owner of $batch_name");
}
$batches[] = $batch;
}
echo "<jobs>\n";
foreach ($batches as $batch) {
$wus = BoincWorkunit::enum("batch = $batch->id");
foreach ($wus as $wu) {
if ($wu->canonical_resultid) {
$status = "DONE";
} else if ($wu->error_mask) {
$status = "ERROR";
} else {
$status = "IN_PROGRESS";
}
echo
" <job>
<job_name>$wu->name</job_name>
<status>$status</status>
</job>
";
}
}
echo "</batch>\n";
echo "</jobs>\n";
}
function query_job($r) {
@ -477,6 +492,11 @@ function get_templates($r) {
echo "<templates>\n$in\n$out\n</templates>\n";
}
function ping($r) {
BoincDb::get(); // errors out if DB down or web disabled
echo "<success>1</success>";
}
if (0) {
$r = simplexml_load_string("
<query_batch>
@ -530,7 +550,10 @@ if (!$r) {
switch ($r->getName()) {
case 'abort_batch': handle_abort_batch($r); break;
case 'abort_jobs': handle_abort_jobs($r); break;
case 'create_batch': create_batch($r); break;
case 'estimate_batch': estimate_batch($r); break;
case 'get_templates': get_templates($r); break;
case 'ping': ping($r); break;
case 'query_batch': query_batch($r); break;
case 'query_batch2': query_batch2($r); break;
case 'query_batches': query_batches($r); break;
@ -538,8 +561,6 @@ switch ($r->getName()) {
case 'query_completed_job': query_completed_job($r); break;
case 'retire_batch': handle_retire_batch($r); break;
case 'submit_batch': submit_batch($r); break;
case 'create_batch': create_batch($r); break;
case 'get_templates': get_templates($r); break;
default: xml_error(-1, "bad command: ".$r->getName());
}

View File

@ -74,7 +74,6 @@ int LOG_FLAGS::parse(XML_PARSER& xp) {
if (xp.parse_bool("cpu_sched_status", cpu_sched_status)) continue;
if (xp.parse_bool("dcf_debug", dcf_debug)) continue;
if (xp.parse_bool("disk_usage_debug", disk_usage_debug)) continue;
if (xp.parse_bool("priority_debug", priority_debug)) continue;
if (xp.parse_bool("file_xfer_debug", file_xfer_debug)) continue;
if (xp.parse_bool("gui_rpc_debug", gui_rpc_debug)) continue;
if (xp.parse_bool("heartbeat_debug", heartbeat_debug)) continue;
@ -84,6 +83,7 @@ int LOG_FLAGS::parse(XML_PARSER& xp) {
if (xp.parse_bool("network_status_debug", network_status_debug)) continue;
if (xp.parse_bool("notice_debug", notice_debug)) continue;
if (xp.parse_bool("poll_debug", poll_debug)) continue;
if (xp.parse_bool("priority_debug", priority_debug)) continue;
if (xp.parse_bool("proxy_debug", proxy_debug)) continue;
if (xp.parse_bool("rr_simulation", rr_simulation)) continue;
if (xp.parse_bool("rrsim_detail", rrsim_detail)) continue;
@ -120,7 +120,6 @@ int LOG_FLAGS::write(MIOFILE& out) {
" <cpu_sched_status>%d</cpu_sched_status>\n"
" <dcf_debug>%d</dcf_debug>\n"
" <disk_usage_debug>%d</disk_usage_debug>\n"
" <priority_debug>%d</priority_debug>\n"
" <file_xfer_debug>%d</file_xfer_debug>\n"
" <gui_rpc_debug>%d</gui_rpc_debug>\n"
" <heartbeat_debug>%d</heartbeat_debug>\n"
@ -130,6 +129,7 @@ int LOG_FLAGS::write(MIOFILE& out) {
" <network_status_debug>%d</network_status_debug>\n"
" <notice_debug>%d</notice_debug>\n"
" <poll_debug>%d</poll_debug>\n"
" <priority_debug>%d</priority_debug>\n"
" <proxy_debug>%d</proxy_debug>\n"
" <rr_simulation>%d</rr_simulation>\n"
" <rrsim_detail>%d</rrsim_detail>\n"
@ -159,7 +159,6 @@ int LOG_FLAGS::write(MIOFILE& out) {
cpu_sched_status ? 1 : 0,
dcf_debug ? 1 : 0,
disk_usage_debug ? 1 : 0,
priority_debug ? 1 : 0,
file_xfer_debug ? 1 : 0,
gui_rpc_debug ? 1 : 0,
heartbeat_debug ? 1 : 0,
@ -169,6 +168,7 @@ int LOG_FLAGS::write(MIOFILE& out) {
network_status_debug ? 1 : 0,
notice_debug ? 1 : 0,
poll_debug ? 1 : 0,
priority_debug ? 1 : 0,
proxy_debug ? 1 : 0,
rr_simulation ? 1 : 0,
rrsim_detail ? 1 : 0,

View File

@ -327,20 +327,22 @@ int submit_jobs(
return retval;
}
int query_batch(
int query_batches(
const char* project_url,
const char* authenticator,
string batch_name,
vector<string> &batch_names,
QUERY_BATCH_REPLY& qb_reply,
string& error_msg
) {
string request;
char url[1024], buf[256];
request = "<query_batch2>\n";
sprintf(buf, "<batch_name>%s</batch_name>\n", batch_name.c_str());
request += string(buf);
sprintf(buf, "<authenticator>%s</authenticator>\n", authenticator);
request += string(buf);
for (unsigned int i=0; i<batch_names.size(); i++) {
sprintf(buf, "<batch_name>%s</batch_name>\n", batch_names[i].c_str());
request += string(buf);
}
request += "</query_batch2>\n";
sprintf(url, "%ssubmit_rpc_handler.php", project_url);
FILE* reply = tmpfile();
@ -354,8 +356,7 @@ int query_batch(
retval = -1;
error_msg = "";
while (fgets(buf, 256, reply)) {
printf("query_batch reply: %s", buf);
if (strstr(buf, "batch")) {
if (strstr(buf, "jobs")) {
retval = 0;
continue;
}
@ -455,6 +456,7 @@ int get_templates(
retval = td.parse(xp);
}
}
fclose(reply);
return retval;
}
@ -564,5 +566,37 @@ int query_completed_job(
retval = jd.parse(xp);
}
}
fclose(reply);
return retval;
}
int ping_server(
const char* project_url,
string &error_msg
) {
string request;
char url[1024], buf[256];
request = "<ping> </ping>\n"; // the space is needed
sprintf(url, "%ssubmit_rpc_handler.php", project_url);
FILE* reply = tmpfile();
vector<string> x;
int retval = do_http_post(url, request.c_str(), reply, x);
if (retval) {
fclose(reply);
return retval;
}
retval = -1;
error_msg = "";
fseek(reply, 0, SEEK_SET);
while (fgets(buf, 256, reply)) {
//printf("reply: %s\n", buf);
if (parse_int(buf, "<error_num>", retval)) continue;
if (parse_str(buf, "<error_msg>", error_msg)) continue;
if (strstr(buf, "success")) {
retval = 0;
continue;
}
}
fclose(reply);
return retval;
}

View File

@ -133,10 +133,10 @@ extern int submit_jobs(
string& error_msg
);
extern int query_batch(
extern int query_batches(
const char* project_url,
const char* authenticator,
string batch_name,
vector<string> &batch_names,
QUERY_BATCH_REPLY& reply,
string& error_msg
);
@ -173,3 +173,8 @@ extern int get_templates(
TEMPLATE_DESC&,
string& error_msg
);
extern int ping_server(
const char* project_url,
string& error_msg
);

View File

@ -54,11 +54,13 @@ struct COMMAND {
char* in;
// the input, in a malloc'd buffer
char* out;
// if NULL the command is in progress; otherwise it's the output
// if NULL the command is in progress;
// otherwise the output in a malloc'd buffer
SUBMIT_REQ submit_req;
FETCH_OUTPUT_REQ fetch_output_req;
vector<string> abort_job_names;
vector<string> batch_names;
char batch_name[256];
COMMAND(char* _in) {
@ -71,7 +73,7 @@ struct COMMAND {
}
int parse_command();
int parse_submit(char*);
int parse_query_batch(char*);
int parse_query_batches(char*);
int parse_fetch_output(char*);
int parse_abort_jobs(char*);
};
@ -243,16 +245,22 @@ void handle_submit(COMMAND& c) {
c.out = strdup(s.c_str());
}
int COMMAND::parse_query_batch(char* p) {
strcpy(batch_name, strtok_r(NULL, " ", &p));
int COMMAND::parse_query_batches(char* p) {
int n = atoi(strtok_r(NULL, " ", &p));
for (int i=0; i<n; i++) {
char* q = strtok_r(NULL, " ", &p);
batch_names.push_back(string(q));
}
return 0;
}
void handle_query_batch(COMMAND&c) {
void handle_query_batches(COMMAND&c) {
QUERY_BATCH_REPLY reply;
char buf[256];
string error_msg, s;
int retval = query_batch(project_url, authenticator, c.batch_name, reply, error_msg);
int retval = query_batches(
project_url, authenticator, c.batch_names, reply, error_msg
);
if (retval) {
sprintf(buf, "error querying batch: %d ", retval);
s = string(buf) + error_msg;
@ -384,16 +392,31 @@ void handle_abort_jobs(COMMAND& c) {
c.out = strdup(s.c_str());
}
void handle_ping(COMMAND& c) {
string error_msg, s;
char buf[256];
int retval = ping_server(project_url, error_msg);
if (retval) {
sprintf(buf, "ping_server returned %d \n", retval);
s = string(buf) + error_msg;
} else {
s = "NULL";
}
c.out = strdup(s.c_str());
}
void* handle_command_aux(void* q) {
COMMAND &c = *((COMMAND*)q);
if (!strcmp(c.cmd, "BOINC_SUBMIT")) {
handle_submit(c);
} else if (!strcmp(c.cmd, "BOINC_QUERY_BATCH")) {
handle_query_batch(c);
} else if (!strcmp(c.cmd, "BOINC_QUERY_BATCHES")) {
handle_query_batches(c);
} else if (!strcmp(c.cmd, "BOINC_FETCH_OUTPUT")) {
handle_fetch_output(c);
} else if (!strcmp(c.cmd, "BOINC_ABORT_JOBS")) {
handle_abort_jobs(c);
} else if (!strcmp(c.cmd, "BOINC_PING")) {
handle_ping(c);
} else {
c.out = strdup("Unknown command");
}
@ -412,12 +435,14 @@ int COMMAND::parse_command() {
q = strtok_r(NULL, " ", &p);
if (!strcmp(cmd, "BOINC_SUBMIT")) {
retval = parse_submit(p);
} else if (!strcmp(cmd, "BOINC_QUERY_BATCH")) {
retval = parse_query_batch(p);
} else if (!strcmp(cmd, "BOINC_QUERY_BATCHES")) {
retval = parse_query_batches(p);
} else if (!strcmp(cmd, "BOINC_FETCH_OUTPUT")) {
retval = parse_fetch_output(p);
} else if (!strcmp(cmd, "BOINC_ABORT_JOBS")) {
retval = parse_abort_jobs(p);
} else if (!strcmp(cmd, "BOINC_PING")) {
retval = 0;
} else {
retval = -1;
}