Skip to content

Commit

Permalink
Merge pull request #5808 from BOINC/dpa_cancel_wus
Browse files Browse the repository at this point in the history
  • Loading branch information
AenBleidd authored Sep 15, 2024
2 parents 2218ef3 + fa2474f commit cef80be
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 10 deletions.
43 changes: 34 additions & 9 deletions html/inc/util_ops.inc
Original file line number Diff line number Diff line change
Expand Up @@ -237,19 +237,32 @@ function current_versions($avs) {
// - set the CANCELLED bit in workunit.error_mask
//
function cancel_wus($wuid1, $wuid2) {
$retval = BoincResult::update_aux("server_state=5, outcome=5 where server_state=2 and $wuid1<=workunitid and workunitid<=$wuid2");
$retval = BoincResult::update_aux(
sprintf(
'server_state=%d, outcome=%d where server_state=%d and workunitid>=%d and workunitid<=%d',
RESULT_SERVER_STATE_OVER,
RESULT_OUTCOME_DIDNT_NEED,
RESULT_SERVER_STATE_UNSENT,
$wuid1, $wuid2
)
);
if (!$retval) {
error_page("Result update failed");
}
$retval = BoincWorkunit::update_aux("error_mask=error_mask|16 where $wuid1<=id and id<=$wuid2");

// mark WUs as cancelled and trigger the transitioner
//
$retval = BoincWorkunit::update_aux(
sprintf(
'error_mask=error_mask|%d, transition_time=%d where id>=%d and id<=%d',
WU_ERROR_CANCELLED,
time(),
$wuid1, $wuid2
)
);
if (!$retval) {
error_page("Workunit update failed");
}

// trigger the transitioner (it will set file_delete_state)

$now = time();
$retval = BoincWorkunit::update_aux("transition_time=$now where $wuid1<=id and id<=$wuid2");
return 0;
}

Expand All @@ -259,9 +272,21 @@ function cancel_wus($wuid1, $wuid2) {
function cancel_wus_if_unsent($id1, $id2) {
$wus = BoincWorkunit::enum("id >= $id1 and id <= $id2");
foreach ($wus as $wu) {
$results = BoincResult::enum("workunitid=$wu->id and server_state > 2");
$results = BoincResult::enum(
sprintf(
'workunitid=%d and server_state > %d',
$wu->id, RESULT_SERVER_STATE_UNSENT
)
);
if (count($results)) continue;
$retval = BoincResult::update_aux("server_state=5, outcome=5 where workunitid=$wu->id");
$retval = BoincResult::update_aux(
sprintf(
'server_state=%d, outcome=%d where workunitid=%d',
RESULT_SERVER_STATE_OVER,
RESULT_OUTCOME_DIDNT_NEED,
$wu->id
)
);
if (!$retval) {
error_page("result update failed");
}
Expand Down
2 changes: 1 addition & 1 deletion html/ops/cancel_workunits.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
$qclause = "";

$minid = get_int('minid', true);
$minid = get_int('maxid', true);
$maxid = get_int('maxid', true);
$list = get_str('list', true);
$uclause = get_str('uclause', true);
$clause = get_str('clause', true);
Expand Down

0 comments on commit cef80be

Please sign in to comment.