Skip to content

Commit

Permalink
Merge pull request #21 from Expensify/ionatan_check_paused_child_jobs
Browse files Browse the repository at this point in the history
Check child jobs in paused state too
  • Loading branch information
quinthar authored Oct 19, 2016
2 parents 1720a62 + 96b96fb commit 7a4c774
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions plugins/Jobs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,10 @@ bool BedrockPlugin_Jobs::processCommand(BedrockNode* node, SQLite& db, BedrockNo
// If we are finishing a job that has child jobs, set its state to paused.
if (SIEquals(request.methodLine, "FinishJob") && _hasPendingChildJobs(db, request.calc64("jobID"))) {
SINFO("Job has child jobs, PAUSING");
if (!db.write("UPDATE jobs SET state=" + SQ("PAUSED") + " WHERE jobID=" + SQ(request.calc64("jobID")) +
";")) {
if (!db.write("UPDATE jobs SET "
"state=" + SQ("PAUSED") + " " +
(request.isSet("data") ? ", data=" + SQ(request["data"]) : "") +
"WHERE jobID=" + SQ(request.calc64("jobID")) + ";")) {
throw "502 Update failed";
}

Expand Down Expand Up @@ -690,7 +692,7 @@ bool BedrockPlugin_Jobs::_hasPendingChildJobs(SQLite& db, int64_t jobID) {
if (!db.read("SELECT 1 "
"FROM jobs "
"WHERE parentJobID = " +
SQ(jobID) + " " + "AND state IN ('QUEUED', 'RUNNING') " + "LIMIT 1;",
SQ(jobID) + " " + "AND state IN ('QUEUED', 'RUNNING', 'PAUSED') " + "LIMIT 1;",
result)) {
throw "502 Select failed";
}
Expand Down

0 comments on commit 7a4c774

Please sign in to comment.