mirror of https://github.com/BOINC/boinc.git
client: remove --app_test option; to use feature, edit app_test.cpp
client: restore CLIENT_STATE::app_test and app_test_file; these aren't used but if I remove the client crashes on exit client: don't delete slot dirs with 'test' in their name worker: count only computing time (not sleep) toward --nsecs wsl_wrapper: add debugging output; fix kill commands
This commit is contained in:
parent
6f0bb03c91
commit
04e6cc17e8
|
@ -48,17 +48,18 @@
|
|||
// You can examine the contents of the slot dir,
|
||||
// and examine the output files in the project dir.
|
||||
|
||||
#include "client_state.h"
|
||||
|
||||
// set to 0 to enable
|
||||
|
||||
#if 1
|
||||
void CLIENT_STATE::app_test_init() {}
|
||||
#else
|
||||
#include "log_flags.h"
|
||||
#include "project.h"
|
||||
#include "client_types.h"
|
||||
#include "result.h"
|
||||
#include "client_state.h"
|
||||
#include "log_flags.h"
|
||||
|
||||
// set to 0 to enable
|
||||
|
||||
#if 0
|
||||
void CLIENT_STATE::app_test_init() {}
|
||||
#else
|
||||
|
||||
|
||||
// The following functions create client data structures
|
||||
// (PROJECT, APP, APP_VERSION, WORKUNIT, RESULT, FILE_REF, FILE_INFO)
|
||||
|
@ -155,7 +156,6 @@ static RESULT* make_result(APP_VERSION *av, WORKUNIT* wu) {
|
|||
// so that the client runs a test job.
|
||||
//
|
||||
void CLIENT_STATE::app_test_init() {
|
||||
|
||||
PROJECT *proj = make_project();
|
||||
|
||||
APP *app = make_app(proj);
|
||||
|
@ -170,10 +170,10 @@ void CLIENT_STATE::app_test_init() {
|
|||
*make_file(app->project, "wsl_wrapper.exe", NULL, MAIN_PROG, false)
|
||||
);
|
||||
av->app_files.push_back(
|
||||
*make_file(app->project, "main.sh", NULL, INPUT_FILE, true)
|
||||
*make_file(app->project, "main", NULL, INPUT_FILE, true)
|
||||
);
|
||||
av->app_files.push_back(
|
||||
*make_file(app->project, "worker", NULL, INPUT_FILE, true)
|
||||
*make_file(app->project, "worker", NULL, INPUT_FILE, false)
|
||||
);
|
||||
|
||||
// can put other stuff here like
|
||||
|
|
|
@ -245,6 +245,8 @@ struct CLIENT_STATE {
|
|||
void process_autologin(bool first);
|
||||
|
||||
// --------------- app_test.cpp:
|
||||
bool app_test; // this and the follow are not used,
|
||||
string app_test_file; // but if I remove them the client crashes on exit. WTF???
|
||||
void app_test_init();
|
||||
|
||||
// --------------- current_version.cpp:
|
||||
|
|
|
@ -227,7 +227,7 @@ void delete_old_slot_dirs() {
|
|||
safe_strcpy(filename, "");
|
||||
retval = dir_scan(filename, dirp, sizeof(filename));
|
||||
if (retval) break;
|
||||
if (!strcmp(filename, "app_test")) {
|
||||
if (strstr(filename, "test")) {
|
||||
continue;
|
||||
}
|
||||
snprintf(path, sizeof(path), "%s/%s", SLOTS_DIR, filename);
|
||||
|
|
|
@ -59,7 +59,6 @@ void copy_uc(FILE* fin, FILE* fout) {
|
|||
int main(int argc, char** argv) {
|
||||
FILE* in=0, *out=0;
|
||||
int i, nsecs = 0;
|
||||
char c;
|
||||
|
||||
for (i=1; i<argc; i++) {
|
||||
if (!strcmp(argv[i], "--nsecs")) {
|
||||
|
@ -95,10 +94,8 @@ int main(int argc, char** argv) {
|
|||
|
||||
copy_uc(in, out);
|
||||
|
||||
int start = (int)time(0);
|
||||
|
||||
i=0;
|
||||
while (time(0) < start+nsecs) {
|
||||
while (clock()/(double)CLOCKS_PER_SEC < nsecs) {
|
||||
do_a_giga_flop(i++);
|
||||
}
|
||||
|
||||
|
@ -168,7 +165,7 @@ int parse_command_line(char* p, char** argv) {
|
|||
return argc;
|
||||
}
|
||||
|
||||
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR Args, int WinMode) {
|
||||
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR Args, int) {
|
||||
LPSTR command_line;
|
||||
char* argv[100];
|
||||
int argc;
|
||||
|
|
|
@ -49,6 +49,8 @@
|
|||
|
||||
using std::string;
|
||||
|
||||
#define VERBOSE 1
|
||||
|
||||
WSL_CMD app_wc;
|
||||
WSL_CMD ctl_wc;
|
||||
int seqno = 0;
|
||||
|
@ -69,29 +71,36 @@ struct RSC_USAGE {
|
|||
}
|
||||
};
|
||||
|
||||
int error(const char* where, int retval) {
|
||||
fprintf(stderr, "%s failed: %d\n", where, retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
// launch application and get process group ID
|
||||
//
|
||||
int launch(const char* distro, const char* cmd) {
|
||||
char launch_cmd[256];
|
||||
sprintf(launch_cmd, "echo $$; %s; touch boinc_job_done\n", cmd);
|
||||
int retval = app_wc.setup();
|
||||
if (retval) return retval;
|
||||
if (retval) return error("app setup", retval);
|
||||
retval = app_wc.run_command(distro, launch_cmd, true);
|
||||
if (retval) return retval;
|
||||
if (retval) return error("app run_command", retval);
|
||||
string reply;
|
||||
retval = read_from_pipe(app_wc.out_read, app_wc.proc_handle, reply, CMD_TIMEOUT, "\n");
|
||||
if (retval) return retval;
|
||||
if (retval) return error("app read_from_pipe", retval);
|
||||
pgid = atoi(reply.c_str());
|
||||
printf("reply: [%s]\n", reply.c_str());
|
||||
printf("pgid: %d\n", pgid);
|
||||
#if VERBOSE
|
||||
fprintf(stderr, "reply: [%s]\n", reply.c_str());
|
||||
fprintf(stderr, "pgid: %d\n", pgid);
|
||||
#endif
|
||||
running = true;
|
||||
|
||||
// set up control channel
|
||||
//
|
||||
retval = ctl_wc.setup();
|
||||
if (retval) return retval;
|
||||
if (retval) return error("ctl setup", retval);
|
||||
retval = ctl_wc.run_command(distro, "", true);
|
||||
if (retval) return retval;
|
||||
if (retval) return error("ctl run_command", retval);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -110,9 +119,13 @@ JOB_STATUS poll_app(RSC_USAGE &ru) {
|
|||
int retval = read_from_pipe(
|
||||
ctl_wc.out_read, ctl_wc.proc_handle, reply, CMD_TIMEOUT, "EOM"
|
||||
);
|
||||
printf("read: %d\n", retval);
|
||||
if (retval) return JOB_FAIL;
|
||||
printf("ps reply: [%s]\n", reply.c_str());
|
||||
if (retval) {
|
||||
error("poll read", retval);
|
||||
return JOB_FAIL;
|
||||
}
|
||||
#if VERBOSE
|
||||
fprintf(stderr, "ps reply: [%s]\n", reply.c_str());
|
||||
#endif
|
||||
ru.clear();
|
||||
int nlines = 0;
|
||||
// the first line produced by the ps command is the rather unhelpful
|
||||
|
@ -130,6 +143,7 @@ JOB_STATUS poll_app(RSC_USAGE &ru) {
|
|||
}
|
||||
if (nlines == 0) {
|
||||
if (boinc_file_exists("boinc_job_done")) return JOB_SUCCESS;
|
||||
fprintf(stderr, "no finish file\n");
|
||||
return JOB_FAIL;
|
||||
}
|
||||
return JOB_IN_PROGRESS;
|
||||
|
@ -137,19 +151,28 @@ JOB_STATUS poll_app(RSC_USAGE &ru) {
|
|||
|
||||
int suspend() {
|
||||
char cmd[256];
|
||||
sprintf(cmd, "kill STOP %d\n", pgid);
|
||||
sprintf(cmd, "kill -STOP %d\n", -pgid); // negative means whole process group
|
||||
running = false;
|
||||
#if VERBOSE
|
||||
fprintf(stderr, "sending %s\n", cmd);
|
||||
#endif
|
||||
return write_to_pipe(ctl_wc.out_write, cmd);
|
||||
}
|
||||
int resume() {
|
||||
char cmd[256];
|
||||
sprintf(cmd, "kill CONT %d\n", pgid);
|
||||
sprintf(cmd, "kill -CONT %d\n", -pgid);
|
||||
running = true;
|
||||
#if VERBOSE
|
||||
fprintf(stderr, "sending %s\n", cmd);
|
||||
#endif
|
||||
return write_to_pipe(ctl_wc.out_write, cmd);
|
||||
}
|
||||
int abort_job() {
|
||||
char cmd[256];
|
||||
sprintf(cmd, "kill KILL %d\n", pgid);
|
||||
sprintf(cmd, "kill -KILL %d\n", -pgid);
|
||||
#if VERBOSE
|
||||
fprintf(stderr, "sending %s\n", cmd);
|
||||
#endif
|
||||
return write_to_pipe(ctl_wc.out_write, cmd);
|
||||
}
|
||||
|
||||
|
@ -157,12 +180,19 @@ void poll_client_msgs() {
|
|||
BOINC_STATUS status;
|
||||
boinc_get_status(&status);
|
||||
if (status.no_heartbeat || status.quit_request || status.abort_request) {
|
||||
fprintf(stderr, "got quite/abort from client\n");
|
||||
abort_job();
|
||||
exit(0);
|
||||
}
|
||||
if (status.suspended) {
|
||||
#if VERBOSE
|
||||
fprintf(stderr, "suspended\n");
|
||||
#endif
|
||||
if (running) suspend();
|
||||
} else {
|
||||
#if VERBOSE
|
||||
fprintf(stderr, "not suspended\n");
|
||||
#endif
|
||||
if (!running) resume();
|
||||
}
|
||||
}
|
||||
|
@ -206,7 +236,7 @@ int main(int argc, char** argv) {
|
|||
char main_cmd[256];
|
||||
sprintf(main_cmd, "./main %s", pass_thru);
|
||||
if (launch(distro_name.c_str(), main_cmd)) {
|
||||
printf("launch failed\n");
|
||||
fprintf(stderr, "launch failed\n");
|
||||
exit(1);
|
||||
}
|
||||
while (1) {
|
||||
|
@ -216,15 +246,17 @@ int main(int argc, char** argv) {
|
|||
RSC_USAGE ru;
|
||||
switch (poll_app(ru)) {
|
||||
case JOB_FAIL:
|
||||
printf("job failed\n");
|
||||
fprintf(stderr, "job failed\n");
|
||||
boinc_finish(1);
|
||||
goto done;
|
||||
case JOB_SUCCESS:
|
||||
printf("job succeeded\n");
|
||||
fprintf(stderr, "job succeeded\n");
|
||||
boinc_finish(0);
|
||||
goto done;
|
||||
}
|
||||
printf("job in progress; cpu: %f wss: %f\n", ru.cpu_time, ru.wss);
|
||||
#if VERBOSE
|
||||
fprintf(stderr, "job in progress; cpu: %f wss: %f\n", ru.cpu_time, ru.wss);
|
||||
#endif
|
||||
boinc_report_app_status(ru.cpu_time, checkpoint_cpu_time, 0);
|
||||
boinc_sleep(POLL_PERIOD);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue