Skip to content

Commit f92d191

Browse files
authored
Merge pull request #6736 from BOINC/dpa_task_exit
Client: use 'abort' rather than 'quit' when appropriate
2 parents fe104ab + aaded25 commit f92d191

File tree

6 files changed

+49
-27
lines changed

6 files changed

+49
-27
lines changed

client/app.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ int ACTIVE_TASK::preempt(PREEMPT_TYPE preempt_type, int reason) {
209209
result->name
210210
);
211211
}
212-
return request_exit();
212+
return request_quit();
213213
} else {
214214
if (show_msg) {
215215
msg_printf(result->project, MSG_INFO,

client/app.h

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -238,33 +238,43 @@ struct ACTIVE_TASK {
238238

239239
// Termination stuff.
240240
// Terminology:
241-
// "kill": forcibly kill the main process and all its descendants.
242-
// "request exit": send a request-exit message, and enumerate descendants.
241+
// "kill" means kill the main process and all its descendants,
242+
// with SIGKILL on Unix or TerminateProcess on Win
243+
// "request_quit": send a quit message, and enumerate descendants.
243244
// If after 15 secs any processes remain, kill them
245+
// Use this if the job will be restarted in the future.
244246
// called from:
245247
// task preemption
246-
// project detach or reset
248+
// client exit
247249
// implementation:
248250
// sends msg, sets quit_time, state QUIT_PENDING;
249251
// get list of descendants
250252
// normal exit handled in handle_premature_exit()
251253
// timeout handled in ACTIVE_TASK_SET::poll()
252-
// "abort_task": like request exit,
253-
// but the app is supposed to write a stack trace to stderr
254-
// called from: rsc exceeded; got ack of running task;
254+
// "request_abort": like request quit,
255+
// but send an abort message rather than quit.
256+
// Use this if the job won't be restarted.
257+
// called from:
258+
// project detach or reset
259+
// rsc limit exceeded
260+
// abort request from server
255261
// intermediate upload failure
256262
// client exiting w/ abort_jobs_on_exit set
263+
// If it gets this, the BOINC API library
264+
// tries to write the call stack to stderr
265+
// so you can e.g. see where an infinite loop happened
257266
//
258-
int request_exit();
267+
int request_quit();
259268
int request_abort();
260269
int kill_running_task(bool will_restart);
261-
// Kill process and subsidiary processes forcibly.
262-
// Unix: send a SIGKILL signal, Windows: TerminateProcess()
270+
// Kill process and subsidiary processes.
263271
int kill_subsidiary_processes();
264272
// kill subsidiary processes of a job
265273
// whose main process has already exited
266274
int abort_task(int exit_status, const char*);
267275
// can be called whether or not process exists
276+
// if process exists, request_abort()
277+
// else just mark task as aborted
268278

269279
// is the GPU task running or suspended (due to CPU throttling)
270280
//
@@ -283,8 +293,8 @@ struct ACTIVE_TASK {
283293
// return true if this task has exited
284294

285295
int suspend();
286-
// tell a process to stop executing (but stay in mem)
287-
// Done by sending it a <suspend> message
296+
// sending process a <suspend> message;
297+
// tells it to stop executing but stay in mem
288298
int unsuspend(int reason=0);
289299
// Undo a suspend: send a <resume> message
290300
int preempt(PREEMPT_TYPE preempt_type, int reason=0);
@@ -338,9 +348,9 @@ class ACTIVE_TASK_SET {
338348
void suspend_all(int reason);
339349
void unsuspend_all(int reason=0);
340350
bool is_task_executing();
341-
void request_tasks_exit(PROJECT* p=0);
342-
int wait_for_exit(double, PROJECT* p=0);
343-
int exit_tasks(PROJECT* p=0);
351+
void request_tasks_exit(bool will_restart, PROJECT* p);
352+
int wait_for_exit(double, PROJECT* p);
353+
int exit_tasks(bool will_restart, PROJECT* p);
344354
void kill_tasks(PROJECT* p=0);
345355
int abort_project(PROJECT*);
346356
void get_msgs();

client/app_control.cpp

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ static void print_descendants(int pid, const vector<int>& desc, const char* wher
199199

200200
// Send a quit message, start timer, get descendants
201201
//
202-
int ACTIVE_TASK::request_exit() {
202+
int ACTIVE_TASK::request_quit() {
203203
if (app_client_shm.shm) {
204204
process_control_queue.msg_queue_send(
205205
"<quit/>",
@@ -1086,18 +1086,21 @@ void ACTIVE_TASK_SET::request_reread_app_info() {
10861086
}
10871087

10881088

1089-
// send quit message to all tasks in the project
1089+
// send quit or abort message to all tasks in the project
10901090
// (or all tasks, if proj is NULL).
10911091
// If they don't exit in QUIT_TIMEOUT seconds,
10921092
// send them a kill signal and wait up to 5 more seconds to exit.
10931093
// This is called when the client exits,
10941094
// or when a project is detached or reset
10951095
//
1096-
int ACTIVE_TASK_SET::exit_tasks(PROJECT* proj) {
1096+
int ACTIVE_TASK_SET::exit_tasks(bool will_restart, PROJECT* proj) {
10971097
if (log_flags.task_debug) {
1098-
msg_printf(NULL, MSG_INFO, "[task_debug] requesting tasks to exit");
1098+
msg_printf(NULL, MSG_INFO,
1099+
"[task_debug] requesting tasks to %s",
1100+
will_restart ? "quit" : "abort"
1101+
);
10991102
}
1100-
request_tasks_exit(proj);
1103+
request_tasks_exit(will_restart, proj);
11011104

11021105
// Wait for tasks to exit normally; if they don't then kill them
11031106
//
@@ -1137,6 +1140,7 @@ int ACTIVE_TASK_SET::exit_tasks(PROJECT* proj) {
11371140
// Wait up to wait_time seconds for processes to exit
11381141
// If proj is zero, wait for all processes, else that project's
11391142
// NOTE: it's bad form to sleep, but it would be complex to avoid it here
1143+
// Return 0 if they all exit.
11401144
//
11411145
int ACTIVE_TASK_SET::wait_for_exit(double wait_time, PROJECT* proj) {
11421146
bool all_exited;
@@ -1166,7 +1170,7 @@ int ACTIVE_TASK_SET::abort_project(PROJECT* project) {
11661170
vector<ACTIVE_TASK*>::iterator task_iter;
11671171
ACTIVE_TASK* atp;
11681172

1169-
exit_tasks(project);
1173+
exit_tasks(false, project);
11701174
task_iter = active_tasks.begin();
11711175
while (task_iter != active_tasks.end()) {
11721176
atp = *task_iter;
@@ -1301,18 +1305,22 @@ bool ACTIVE_TASK_SET::is_task_executing() {
13011305
return false;
13021306
}
13031307

1304-
// Send quit message to all app processes
1308+
// Send quit or abort message to all app processes
13051309
// This is called when the client exits,
13061310
// or when a project is detached or reset
13071311
//
1308-
void ACTIVE_TASK_SET::request_tasks_exit(PROJECT* proj) {
1312+
void ACTIVE_TASK_SET::request_tasks_exit(bool will_restart, PROJECT* proj) {
13091313
unsigned int i;
13101314
ACTIVE_TASK *atp;
13111315
for (i=0; i<active_tasks.size(); i++) {
13121316
atp = active_tasks[i];
13131317
if (proj && atp->wup->project != proj) continue;
13141318
if (!atp->process_exists()) continue;
1315-
atp->request_exit();
1319+
if (will_restart) {
1320+
atp->request_quit();
1321+
} else {
1322+
atp->request_abort();
1323+
}
13161324
}
13171325
}
13181326

client/client_state.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2355,7 +2355,7 @@ int CLIENT_STATE::quit_activities() {
23552355
// Do this last because it could take a long time,
23562356
// and the OS might kill us in the middle
23572357
//
2358-
int retval = active_tasks.exit_tasks();
2358+
int retval = active_tasks.exit_tasks(true, NULL);
23592359
if (retval) {
23602360
msg_printf(NULL, MSG_INTERNAL_ERROR,
23612361
"Couldn't exit tasks: %s", boincerror(retval)

client/sim_util.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ int ACTIVE_TASK::suspend() {
114114
return 0;
115115
}
116116

117-
int ACTIVE_TASK::request_exit() {
118-
set_task_state(PROCESS_UNINITIALIZED, "request_exit");
117+
int ACTIVE_TASK::request_quit() {
118+
set_task_state(PROCESS_UNINITIALIZED, "request_quit");
119119
return 0;
120120
}
121121

lib/util.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,10 @@ int DOCKER_CONN::parse_image_name(string line, string &name) {
816816
// CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
817817
// 6d4877e0d071 localhost/boinc__app_test__test_wu:latest /bin/sh -c ./work... 43 hours ago Exited (0) 21 hours ago boinc__app_test__test_result
818818
//
819+
// if running, looks like
820+
// CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
821+
// bf4ce6e19182 localhost/criu_test:latest ./counter.sh 9 seconds ago Up 9 seconds competent_ishizaka
822+
819823
int DOCKER_CONN::parse_container_name(string line, string &name) {
820824
char buf[1024];
821825
strcpy(buf, line.c_str());

0 commit comments

Comments
 (0)