From 558d76212f10a1850caed2b99bad1b7cee3c3adb Mon Sep 17 00:00:00 2001 From: David Anderson Date: Mon, 2 Jun 2014 19:01:44 -0700 Subject: [PATCH] server: fix race condition when creating targeted jobs. We were creating the workunit, then updating its transitioner_flags field. If the transitioner runs inbetween, it would (incorrectly) create results for the workunit. Solution: set transitioner_flags during insert. --- tools/backend_lib.cpp | 2 +- tools/create_work.cpp | 12 +++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/tools/backend_lib.cpp b/tools/backend_lib.cpp index 562fdc961f..9369906838 100644 --- a/tools/backend_lib.cpp +++ b/tools/backend_lib.cpp @@ -346,7 +346,7 @@ int create_work2( fprintf(stderr, "target_nresults > max_success_results; can't create job\n"); return ERR_INVALID_PARAM; } - if (wu.transitioner_flags & TRANSITION_NONE) { + if (wu.transitioner_flags) { wu.transition_time = INT_MAX; } else { wu.transition_time = time(0); diff --git a/tools/create_work.cpp b/tools/create_work.cpp index ad7a286432..bf8ec8ec1d 100644 --- a/tools/create_work.cpp +++ b/tools/create_work.cpp @@ -434,7 +434,9 @@ int main(int argc, char** argv) { } void JOB_DESC::create() { - char buf[256]; + if (assign_flag) { + wu.transitioner_flags = assign_multi?TRANSITION_NONE:TRANSITION_NO_NEW_RESULTS; + } int retval = create_work2( wu, wu_template, @@ -464,14 +466,6 @@ void JOB_DESC::create() { ); exit(1); } - sprintf(buf, "transitioner_flags=%d", - assign_multi?TRANSITION_NONE:TRANSITION_NO_NEW_RESULTS - ); - retval = wu.update_field(buf); - if (retval) { - fprintf(stderr, "wu.update() failed: %s\n", boincerror(retval)); - exit(1); - } } }