2003-09-27 23:20:40 +00:00
|
|
|
// The contents of this file are subject to the BOINC Public License
|
|
|
|
// Version 1.0 (the "License"); you may not use this file except in
|
|
|
|
// compliance with the License. You may obtain a copy of the License at
|
|
|
|
// http://boinc.berkeley.edu/license_1.0.txt
|
|
|
|
//
|
|
|
|
// Software distributed under the License is distributed on an "AS IS"
|
|
|
|
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
|
|
|
// License for the specific language governing rights and limitations
|
|
|
|
// under the License.
|
|
|
|
//
|
|
|
|
// The Original Code is the Berkeley Open Infrastructure for Network Computing.
|
|
|
|
//
|
|
|
|
// The Initial Developer of the Original Code is the SETI@home project.
|
|
|
|
// Portions created by the SETI@home project are Copyright (C) 2002
|
|
|
|
// University of California at Berkeley. All Rights Reserved.
|
|
|
|
//
|
|
|
|
// Contributor(s):
|
|
|
|
//
|
|
|
|
|
2003-10-07 04:47:00 +00:00
|
|
|
// wu_check [-repair]
|
|
|
|
// look for results with missing input files
|
|
|
|
// -repair change them to server_state OVER, outcome COULDNT_SEND
|
|
|
|
|
2003-09-27 23:20:40 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "parse.h"
|
|
|
|
#include "boinc_db.h"
|
|
|
|
#include "sched_config.h"
|
|
|
|
|
2003-10-07 04:47:00 +00:00
|
|
|
bool repair = false;
|
|
|
|
|
2003-09-27 23:20:40 +00:00
|
|
|
// wu_checker
|
|
|
|
// See whether input files that should be present, are
|
|
|
|
|
|
|
|
SCHED_CONFIG config;
|
|
|
|
|
|
|
|
// get the path a WU's input file
|
|
|
|
//
|
|
|
|
int get_file_path(WORKUNIT& wu, char* path) {
|
|
|
|
char buf[256];
|
|
|
|
bool flag;
|
|
|
|
flag = parse_str(wu.xml_doc, "<name>", buf, sizeof(buf));
|
|
|
|
if (!flag) return -1;
|
2003-10-10 22:55:29 +00:00
|
|
|
sprintf(path, "%s/%s", config.download_dir, buf);
|
2003-09-27 23:20:40 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-10-10 22:55:29 +00:00
|
|
|
int handle_result(DB_RESULT& result) {
|
2003-09-27 23:20:40 +00:00
|
|
|
DB_WORKUNIT wu;
|
|
|
|
int retval;
|
|
|
|
char path[256];
|
|
|
|
FILE* f;
|
|
|
|
|
|
|
|
retval = wu.lookup_id(result.workunitid);
|
|
|
|
if (retval) {
|
|
|
|
printf(
|
|
|
|
"ERROR: can't find WU %d for result %d\n",
|
|
|
|
result.workunitid, result.id
|
|
|
|
);
|
2003-10-10 22:55:29 +00:00
|
|
|
return 1;
|
2003-09-27 23:20:40 +00:00
|
|
|
}
|
|
|
|
get_file_path(wu, path);
|
|
|
|
f = fopen(path, "r");
|
|
|
|
if (f) {
|
|
|
|
fclose(f);
|
|
|
|
} else {
|
2003-10-10 22:55:29 +00:00
|
|
|
printf("no file %s for result %d\n",
|
2003-09-27 23:20:40 +00:00
|
|
|
path, result.id
|
|
|
|
);
|
2003-10-07 04:47:00 +00:00
|
|
|
if (repair) {
|
|
|
|
if (result.server_state == RESULT_SERVER_STATE_UNSENT) {
|
|
|
|
result.server_state = RESULT_SERVER_STATE_OVER;
|
|
|
|
result.outcome = RESULT_OUTCOME_COULDNT_SEND;
|
|
|
|
result.update();
|
|
|
|
}
|
|
|
|
}
|
2003-10-10 22:55:29 +00:00
|
|
|
return 1;
|
2003-09-27 23:20:40 +00:00
|
|
|
}
|
2003-10-10 22:55:29 +00:00
|
|
|
return 0;
|
2003-09-27 23:20:40 +00:00
|
|
|
}
|
|
|
|
|
2003-10-07 04:47:00 +00:00
|
|
|
int main(int argc, char** argv) {
|
2003-09-27 23:20:40 +00:00
|
|
|
DB_RESULT result;
|
|
|
|
char clause[256];
|
2003-10-10 22:55:29 +00:00
|
|
|
int retval, n, nerr;
|
2003-10-07 04:47:00 +00:00
|
|
|
|
|
|
|
retval = config.parse_file();
|
|
|
|
if (retval) exit(1);
|
2003-09-27 23:20:40 +00:00
|
|
|
|
2003-10-10 22:55:29 +00:00
|
|
|
retval = boinc_db.open(config.db_name, config.db_passwd);
|
|
|
|
if (retval) {
|
|
|
|
printf("boinc_db.open: %d\n", retval);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (argc > 1 && !strcmp(argv[1], "-repair")) repair = true;
|
2003-09-27 23:20:40 +00:00
|
|
|
|
2003-10-10 22:55:29 +00:00
|
|
|
n = nerr = 0;
|
|
|
|
printf("Unsent results:\n");
|
2003-09-27 23:20:40 +00:00
|
|
|
sprintf(clause, "where server_state=%d", RESULT_SERVER_STATE_UNSENT);
|
|
|
|
while (!result.enumerate(clause)) {
|
2003-10-10 22:55:29 +00:00
|
|
|
retval = handle_result(result);
|
|
|
|
n++;
|
|
|
|
if (retval) nerr++;
|
2003-09-27 23:20:40 +00:00
|
|
|
}
|
2003-10-10 22:55:29 +00:00
|
|
|
printf("%d out of %d errors\n", nerr, n);
|
|
|
|
n = nerr = 0;
|
|
|
|
printf("In progress results:\n");
|
2003-09-27 23:20:40 +00:00
|
|
|
sprintf(clause, "where server_state=%d", RESULT_SERVER_STATE_IN_PROGRESS);
|
|
|
|
while (!result.enumerate(clause)) {
|
2003-10-10 22:55:29 +00:00
|
|
|
retval = handle_result(result);
|
|
|
|
n++;
|
|
|
|
if (retval) nerr++;
|
2003-09-27 23:20:40 +00:00
|
|
|
}
|
2003-10-10 22:55:29 +00:00
|
|
|
printf("%d out of %d errors\n", nerr, n);
|
2003-09-27 23:20:40 +00:00
|
|
|
}
|