*** empty log message ***

svn path=/trunk/boinc/; revision=2525
This commit is contained in:
David Anderson 2003-10-21 04:06:55 +00:00
parent ae835ae029
commit 5589d5368f
17 changed files with 109 additions and 76 deletions

View File

@ -359,7 +359,7 @@ int ACTIVE_TASK::start(bool first_time) {
if (win_error) {
gstate.report_result_error(*result, win_error, (LPTSTR)&lpMsgBuf);
LocalFree(lpMsgBuf);
return -1;
return ERR_EXEC;
}
msg_printf(wup->project, MSG_ERROR, "CreateProcess: %s", (LPCTSTR)lpMsgBuf);
LocalFree(lpMsgBuf);
@ -385,7 +385,7 @@ int ACTIVE_TASK::start(bool first_time) {
result->active_task_state = PROCESS_COULDNT_START;
gstate.report_result_error(*result, -1, strerror(errno));
msg_printf(wup->project, MSG_ERROR, "fork(): %s", strerror(errno));
return -1;
return ERR_FORK;
}
if (pid == 0) {
// from here on we're running in a new process.
@ -859,7 +859,7 @@ int ACTIVE_TASK_SET::wait_for_exit(double wait_time, PROJECT* proj) {
boinc_sleep(wait_time/10.0);
}
return -1;
return ERR_NOT_EXITED;
}
int ACTIVE_TASK_SET::abort_project(PROJECT* project) {
@ -1060,7 +1060,7 @@ int ACTIVE_TASK::get_cpu_time_via_os() {
#else
// On UNIX, we can't get CPU time before process has exited for some reason
#endif
return -1;
return ERR_NOT_IMPLEMENTED;
}
// See if the app has generated a new fraction-done message in shared mem.
@ -1106,7 +1106,7 @@ int ACTIVE_TASK::get_cpu_time_via_shmem(time_t now) {
last_status_msg_time = now;
return get_cpu_time_via_os();
}
return -1;
return ERR_NOT_IMPLEMENTED;
}
// get CPU times of active tasks
@ -1215,14 +1215,14 @@ int ACTIVE_TASK::parse(FILE* fin, CLIENT_STATE* cs) {
"ACTIVE_TASK::parse(): project not found: %s\n",
project_master_url
);
return -1;
return ERR_NULL;
}
result = cs->lookup_result(project, result_name);
if (!result) {
msg_printf(
NULL, MSG_ERROR, "ACTIVE_TASK::parse(): result not found\n"
);
return -1;
return ERR_NULL;
}
wup = result->wup;
app_version = cs->lookup_app_version(
@ -1244,7 +1244,7 @@ int ACTIVE_TASK::parse(FILE* fin, CLIENT_STATE* cs) {
else if (parse_double(buf, "<checkpoint_cpu_time>", checkpoint_cpu_time)) continue;
else msg_printf(NULL, MSG_ERROR, "ACTIVE_TASK::parse(): unrecognized %s\n", buf);
}
return -1;
return ERR_XML_PARSE;
}
// Write XML information about this active task set

View File

@ -131,10 +131,11 @@ int CLIENT_STATE::cpu_benchmarks() {
// need to check cache!!
host_info.m_cache = 1e6;
msg_printf(NULL, MSG_INFO, "Benchmark results: FP: %.0f million op/sec%s; Int: %.0f million op/sec%s; Mem BW: %.0f million bytes/sec%s",
host_info.p_fpops/1e6, (host_info.p_fpop_err?" [ERROR]":""),
host_info.p_iops/1e6, (host_info.p_iop_err?" [ERROR]":""),
host_info.p_membw/1e6, (host_info.p_membw_err?" [ERROR]":"")
msg_printf(
NULL, MSG_INFO, "Benchmark results: FP: %.0f million op/sec%s; Int: %.0f million op/sec%s; Mem BW: %.0f million bytes/sec%s",
host_info.p_fpops/1e6, (host_info.p_fpop_err?" [ERROR]":""),
host_info.p_iops/1e6, (host_info.p_iop_err?" [ERROR]":""),
host_info.p_membw/1e6, (host_info.p_membw_err?" [ERROR]":"")
);
}

View File

@ -224,9 +224,9 @@ int HOST_INFO::write_cpu_benchmarks(FILE* out) {
int get_local_domain_name(char* p, int len) {
char buf[256];
if (gethostname(buf, 256)) return -1;
if (gethostname(buf, 256)) return ERR_GETHOSTBYNAME;
struct hostent* he = gethostbyname(buf);
if (!he) return -1;
if (!he) return ERR_GETHOSTBYNAME;
safe_strncpy(p, he->h_name, len);
return 0;
}
@ -240,12 +240,12 @@ int get_local_ip_addr_str(char* p, int len) {
struct in_addr addr;
if (gethostname(buf, 256)) {
printf("gethostname() didn't return name\n");
return -1;
return ERR_GETHOSTNAME;
}
struct hostent* he = gethostbyname(buf);
if (!he || !he->h_addr_list[0]) {
printf("gethostbyname() didn't return any IP addresses\n");
return -1;
return ERR_GETHOSTBYNAME;
}
memcpy(&addr, he->h_addr_list[0], sizeof(addr));
safe_strncpy(p, inet_ntoa(addr), len);
@ -261,10 +261,11 @@ int get_local_ip_addr(int& p) {
#if HAVE_NETDB_H || _WIN32
char buf[256];
struct in_addr addr;
if (gethostname(buf, 256))
return -1;
if (gethostname(buf, 256)) {
return ERR_GETHOSTNAME;
}
struct hostent* he = gethostbyname(buf);
if (!he) return -1;
if (!he) return ERR_GETHOSTBYNAME;
memcpy(&addr, he->h_addr_list[0], sizeof(addr));
p = addr.s_addr;
#endif

View File

@ -90,7 +90,9 @@ int NET_XFER::get_ip_addr(char *hostname, int &ip_addr) {
hostent* hep;
#ifdef _WIN32
if(NetOpen()) return -1;
int retval;
retval = NetOpen();
if (retval) return retval;
#endif
hep = gethostbyname(hostname);
if (!hep) {
@ -171,7 +173,7 @@ int NET_XFER::open_server() {
#ifdef _WIN32
NetClose();
#endif
return -1;
return ERR_SOCKET;
}
#ifdef _WIN32
@ -180,8 +182,8 @@ int NET_XFER::open_server() {
#else
int flags;
flags = fcntl(fd, F_GETFL, 0);
if (flags < 0) return -1;
else if (fcntl(fd, F_SETFL, flags|O_NONBLOCK) < 0 ) return -1;
if (flags < 0) return ERR_FCNTL;
else if (fcntl(fd, F_SETFL, flags|O_NONBLOCK) < 0 ) return ERR_FCNTL;
#endif
addr.sin_family = AF_INET;
@ -194,7 +196,7 @@ int NET_XFER::open_server() {
if (errno != WSAEINPROGRESS && errno != WSAEWOULDBLOCK) {
closesocket(fd);
NetClose();
return -1;
return ERR_CONNECT;
}
#ifndef WIN_CLI
if (WSAAsyncSelect( fd, g_myWnd->GetSafeHwnd(), g_myWnd->m_nNetActivityMsg, FD_READ|FD_WRITE )) {
@ -202,7 +204,7 @@ int NET_XFER::open_server() {
if (errno != WSAEINPROGRESS && errno != WSAEWOULDBLOCK) {
closesocket(fd);
NetClose();
return -1;
return ERR_ASYNCSELECT;
}
}
#endif
@ -210,7 +212,7 @@ int NET_XFER::open_server() {
if (errno != EINPROGRESS) {
close(fd);
perror("connect");
return -1;
return ERR_CONNECT;
}
#endif
} else {

View File

@ -231,7 +231,7 @@ int parse_graphics_file(FILE* f, GRAPHICS_INFO* gi) {
else if (parse_double(buf, "<graphics_refresh_period>", gi->refresh_period)) continue;
else fprintf(stderr, "parse_graphics_file: unrecognized %s", buf);
}
return -1;
return ERR_XML_PARSE;
}
// create a file (new_link) which contains an XML

View File

@ -80,7 +80,7 @@ int scan_hex_data(FILE* f, DATA_BLOCK& x) {
int i, j;
while (1) {
p = fgets(buf, 256, f);
if (!p) return -1;
if (!p) return ERR_GETS;
n = strlen(p)/2;
if (n == 0) break;
for (i=0; i<n; i++) {
@ -152,12 +152,12 @@ int scan_key_hex(FILE* f, KEY* key, int size) {
len = size - sizeof(key->bits);
while (1) {
p = fgets(buf, 256, f);
if (!p) return -1;
if (!p) return ERR_GETS;
n = strlen(p)/2;
if (n == 0) break;
for (i=0; i<n; i++) {
sscanf(buf+i*2, "%2x", &b);
if (j >= len) return -1;
if (j >= len) return ERR_SCANF;
key->data[j++] = b;
}
}
@ -188,9 +188,9 @@ int sscan_key_hex(char* buf, KEY* key, int size) {
key->bits = num_bits; //key->bits is a short
//fprintf(stderr, "key->bits = %d\n", key->bits);
if (n != 1) return -1;
if (n != 1) return ERR_SCANF;
buf = strchr(buf, '\n');
if (!buf) return -1;
if (!buf) return ERR_STRCHR;
buf += 1;
db.data = key->data;
db.len = size - sizeof(key->bits); //huh???
@ -344,13 +344,13 @@ int read_key_file(char* keyfile, R_RSA_PRIVATE_KEY& key) {
FILE* fkey = fopen(keyfile, "r");
if (!fkey) {
fprintf(stderr, "can't open key file (%s)\n", keyfile);
return -1;
return ERR_FOPEN;
}
retval = scan_key_hex(fkey, (KEY*)&key, sizeof(key));
fclose(fkey);
if (retval) {
fprintf(stderr, "can't parse key\n");
return -1;
return retval;
}
return 0;
}

View File

@ -44,7 +44,7 @@
// unexpected NULL pointer
#define ERR_NEG -117
// unexpected negative value
#define ERR_BUFF_OVERFLOW -118
#define ERR_BUFFER_OVERFLOW -118
// caught buffer overflow
#define ERR_MD5_FAILED -119
// MD5 checksum failed for a file
@ -77,3 +77,27 @@
#define ERR_DB_NOT_UNIQUE -137
// not unique in lookup()
#define ERR_DB_CANT_CONNECT -138
#define ERR_GETS -139
// gets() or fgets()
#define ERR_SCANF -140
// scanf() or fscanf()
#define ERR_STRCHR -141
#define ERR_STRSTR -142
#define ERR_READDIR -143
#define ERR_SHMGET -144
#define ERR_SHMCTL -145
#define ERR_SHMAT -146
#define ERR_FORK -147
#define ERR_EXEC -148
#define ERR_NOT_EXITED -149
// a process didn't exit that was supposed to
#define ERR_NOT_IMPLEMENTED -150
// a system call not implemented on this platform
#define ERR_GETHOSTNAME -151
#define ERR_NETOPEN -152
#define ERR_SOCKET -153
#define ERR_FCNTL -154
#define ERR_AUTHENTICATOR -155
// scheduler request host ID doesn't match authenticator
#define ERR_SCHED_SHMEM -156
// sched shmem has bad contents

View File

@ -115,7 +115,7 @@ int dir_scan(char* p, DIRREF dirp, int p_len) {
if (p) safe_strncpy(p, dp->d_name, p_len);
return 0;
} else {
return -1;
return ERR_READDIR;
}
}
#endif
@ -126,7 +126,7 @@ int dir_scan(char* p, DIRREF dirp, int p_len) {
dirp->first = false;
dirp->handle = FindFirstFile(dirp->path, &data);
if (dirp->handle == INVALID_HANDLE_VALUE) {
return -1;
return ERR_READDIR;
} else {
if (data.cFileName[0] == '.') continue;
if (p) safe_strncpy(p, data.cFileName, p_len);
@ -275,7 +275,7 @@ int clean_out_dir(char* dirpath) {
DIRREF dirp;
dirp = dir_open(dirpath);
if (!dirp) return -1;
if (!dirp) return ERR_OPENDIR;
while (1) {
strcpy(filename, "");
retval = dir_scan(filename, dirp, sizeof(filename));
@ -303,7 +303,7 @@ int dir_size(char* dirpath, double& size) {
size = 0;
dirp = dir_open(dirpath);
if (!dirp) return -1;
if (!dirp) return ERR_OPENDIR;
while (1) {
retval = dir_scan(filename, dirp, sizeof(filename));
if (retval) break;

View File

@ -35,7 +35,7 @@ int md5_file(char* path, char* output, double& nbytes) {
if (!f) {
fprintf(stderr, "md5_file: can't open %s\n", path);
perror("md5_file");
return -1;
return ERR_FOPEN;
}
md5_init(&state);
while (1) {

View File

@ -154,7 +154,7 @@ int dup_element_contents(FILE* in, const char* end_tag, char** pp) {
strcatdup(p, buf);
}
fprintf(stderr, "dup_element_contents(): no end tag\n");
return 1;
return ERR_XML_PARSE;
}
// copy from a file to static buffer
@ -170,7 +170,7 @@ int copy_element_contents(FILE* in, const char* end_tag, char* p, int len) {
strcat(p, buf);
}
fprintf(stderr, "copy_element_contents(): no end tag\n");
return 1;
return ERR_XML_PARSE;
}
// read a file into a malloc'd string
@ -180,7 +180,7 @@ int read_file_malloc(const char* pathname, char*& str) {
FILE* f;
f = fopen(pathname, "r");
if (!f) return -1;
if (!f) return ERR_FOPEN;
str = strdup("");
while (fgets(buf, 256, f)) {
strcatdup(str, buf);

View File

@ -38,6 +38,7 @@
#endif
#include <assert.h>
#include "error_numbers.h"
#include "shmem.h"
#ifdef _WIN32
@ -92,7 +93,7 @@ int create_shmem(key_t key, int size, void** pp) {
if (id < 0) {
sprintf(buf, "create_shmem: shmget: key: %x size: %d", (unsigned int)key, size);
perror(buf);
return -1;
return ERR_SHMGET;
}
return attach_shmem(key, pp);
@ -105,18 +106,18 @@ int destroy_shmem(key_t key){
id = shmget(key, 0, 0);
if (id < 0) return 0; // assume it doesn't exist
retval = shmctl(id, IPC_STAT, &buf);
if (retval) return -1;
if (retval) return ERR_SHMCTL;
if (buf.shm_nattch > 0) {
fprintf(stderr,
"destroy_shmem: can't destroy segment; %d attachments\n",
(int)buf.shm_nattch
);
return -1;
return ERR_SHMCTL;
}
retval = shmctl(id, IPC_RMID, 0);
if (retval) {
fprintf(stderr, "destroy_shmem: remove failed %d\n", retval);
return -1;
return ERR_SHMCTL;
}
return 0;
}
@ -130,13 +131,13 @@ int attach_shmem(key_t key, void** pp){
if (id < 0) {
sprintf(buf, "attach_shmem: shmget: key: %x mem_addr: %p", (unsigned int)key, (void*)pp);
perror(buf);
return -1;
return ERR_SHMGET;
}
p = shmat(id, 0, 0);
if ((long)p == -1) {
if ((long)p == ERR_SHMAT) {
sprintf(buf, "attach_shmem: shmat: key: %x mem_addr: %p", (unsigned int)key, (void*)pp);
perror(buf);
return -1;
return ERR_SHMAT;
}
*pp = p;
return 0;
@ -159,7 +160,7 @@ int shmem_info(key_t key) {
if (id < 0) {
sprintf(buf2, "shmem_info: shmget: key: %x", (unsigned int)key);
perror(buf2);
return -1;
return ERR_SHMGET;
}
shmctl(id, IPC_STAT, &buf);
fprintf( stderr, "shmem key: %x\t\tid: %d, size: %d, nattach: %d\n",

View File

@ -56,7 +56,7 @@ int ndays_to_string (double x, int smallest_timescale, char *buf) {
double years, days, hours, minutes, seconds;
char year_buf[64], day_buf[16], hour_buf[16], min_buf[16], sec_buf[16];
if (x < 0 || buf == NULL) return -1;
if (x < 0 || buf == NULL) return ERR_NULL;
years = x / 365.25;
days = fmod(x, 365.25);
@ -498,7 +498,7 @@ string timediff_format(long tdiff) {
int read_file_string(const char* pathname, string& result) {
result.erase();
ifstream f(pathname);
if (!f) return -1;
if (!f) return ERR_FOPEN;
char c;
while (f.get(c)) result += c;

View File

@ -33,6 +33,7 @@ using namespace std;
#include "boinc_db.h"
#include "backend_lib.h"
#include "error_numbers.h"
#include "parse.h"
#include "util.h"
#include "server_types.h"
@ -111,12 +112,12 @@ int insert_after(char* buffer, char* after, char* text) {
if (strlen(buffer) + strlen(text) > MAX_BLOB_SIZE-1) {
log_messages.printf(SchedMessages::NORMAL, "insert_after: overflow\n");
return -1;
return ERR_BUFFER_OVERFLOW;
}
p = strstr(buffer, after);
if (!p) {
log_messages.printf(SchedMessages::CRITICAL, "insert_after: %s not found in %s\n", after, buffer);
return -1;
return ERR_NULL;
}
p += strlen(after);
strcpy(temp, p);
@ -235,7 +236,7 @@ int add_wu_to_reply(
log_messages.printf(
SchedMessages::CRITICAL, "Can't find APP#%d\n", wu.appid
);
return -1;
return ERR_NULL;
}
avp = ss.lookup_app_version(app->id, platform.id, app->min_version);
if (!avp) {
@ -244,7 +245,7 @@ int add_wu_to_reply(
"Can't find app version: APP#%d PLATFORM#%d min_version %d\n",
app->id, platform.id, app->min_version
);
return -1;
return ERR_NULL;
}
// add the app, app_version, and workunit to the reply,
@ -314,7 +315,7 @@ int authenticate_user(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) {
"[HOST#%d] [USER#%d?] can't find user record\n",
host.id, reply.host.userid
);
return -1;
return retval;
}
reply.user = user;
if (strcmp(sreq.authenticator, reply.user.authenticator)) {
@ -330,7 +331,7 @@ int authenticate_user(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) {
"[HOST#%d] [USER#%d] Bad authenticator '%s'\n",
host.id, user.id, sreq.authenticator
);
return -1;
return ERR_AUTHENTICATOR;
}
// If the seqno from the host is less than what we expect,
@ -363,7 +364,7 @@ int authenticate_user(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) {
"[HOST#<none>] Bad authenticator '%s'\n",
sreq.authenticator
);
return -1;
return ERR_AUTHENTICATOR;
}
reply.user = user;
new_host:
@ -382,7 +383,7 @@ new_host:
strcpy(reply.message_priority, "low");
boinc_db.print_error("host.insert()");
log_messages.printf(SchedMessages::CRITICAL, "host.insert() failed\n");
return -1;
return retval;
}
host.id = boinc_db.insert_id();

View File

@ -26,6 +26,7 @@
#include <assert.h>
#include "boinc_db.h"
#include "error_numbers.h"
#include "sched_shmem.h"
#include "sched_util.h"
@ -45,15 +46,15 @@ void SCHED_SHMEM::init() {
}
int SCHED_SHMEM::verify() {
if (ss_size != sizeof(SCHED_SHMEM)) return -1;
if (platform_size != sizeof(PLATFORM)) return -1;
if (app_size != sizeof(APP)) return -1;
if (app_version_size != sizeof(APP_VERSION)) return -1;
if (wu_result_size != sizeof(WU_RESULT)) return -1;
if (max_platforms != MAX_PLATFORMS) return -1;
if (max_apps != MAX_APPS) return -1;
if (max_app_versions != MAX_APP_VERSIONS) return -1;
if (max_wu_results != MAX_WU_RESULTS) return -1;
if (ss_size != sizeof(SCHED_SHMEM)) return ERR_SCHED_SHMEM;
if (platform_size != sizeof(PLATFORM)) return ERR_SCHED_SHMEM;
if (app_size != sizeof(APP)) return ERR_SCHED_SHMEM;
if (app_version_size != sizeof(APP_VERSION)) return ERR_SCHED_SHMEM;
if (wu_result_size != sizeof(WU_RESULT)) return ERR_SCHED_SHMEM;
if (max_platforms != MAX_PLATFORMS) return ERR_SCHED_SHMEM;
if (max_apps != MAX_APPS) return ERR_SCHED_SHMEM;
if (max_app_versions != MAX_APP_VERSIONS) return ERR_SCHED_SHMEM;
if (max_wu_results != MAX_WU_RESULTS) return ERR_SCHED_SHMEM;
return 0;
}

View File

@ -22,12 +22,13 @@
// (see validate_trivial.C),
// or that requires strict or fuzzy equality.
#include <cassert>
#include "validate_util.h"
#include "sched_util.h"
#include "sched_config.h"
#include "error_numbers.h"
#include "parse.h"
#include <cassert>
#include "validate_util.h"
extern SCHED_CONFIG config;
@ -38,7 +39,7 @@ int get_output_file_path(RESULT const& result, string& path) {
bool flag;
flag = parse_str(result.xml_doc_in, "<name>", buf, sizeof(buf));
if (!flag) return -1;
if (!flag) return ERR_XML_PARSE;
path = config.upload_dir;
path += '/';
path += buf;

View File

@ -40,7 +40,7 @@ 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;
if (!flag) return ERR_XML_PARSE;
sprintf(path, "%s/%s", config.download_dir, buf);
return 0;
}

5
todo
View File

@ -1,8 +1,9 @@
hook up graphics prefs to graphics
reject spamming clients w/o DB lookup
message window is slightly scrolled
Don't render graphics if minimized
add executable approval to win GUI
prevent one host from marking results as CANT_SEND
add a mechanism for server to send messages to client, shown in graphics
use "external app" mechanism (Karl)?
------------------------
DON'T ADD ANYTHING TO HERE. USE THE TASKBASE INSTEAD.