From: Zhang Qiang Date: Sun, 18 Nov 2012 12:46:09 +0000 (+0800) Subject: lock shared vars operations to avoid race condition X-Git-Tag: 0.3~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3a7dc41df2d9032da441be9f702f22804610b9f0;p=tools%2Fdepanneur.git lock shared vars operations to avoid race condition Basic workflow: Main thread: %to_build: all packages need to be built %order: ready packages queue <*> scheduler to resolve ready packages in time shared data: @done: @building: threads: * Push packages from @building to @done * Trigger local repo update Change-Id: Ib48b1c5225a045a8bd3017ff8e0ea656ccc72c97 --- diff --git a/depanneur b/depanneur index 51b3018..35d46bc 100755 --- a/depanneur +++ b/depanneur @@ -1445,20 +1445,20 @@ while (! $TERM) { } } } + # No candidate packges and all thread works are idle, and pkgdeps + # is updated, in this case, set packages in %tmp_expansion_errors + # as real expansion_errors, and all packages depend on these packages + # can not be blocked. + if (@order == 0 && threads->list() == 0 && $dirty == 0) { + @expansion_errors{keys %tmp_expansion_errors} = values %tmp_expansion_errors; + } + if (scalar(keys %to_build) == @done + @skipped + + scalar(keys %expansion_errors) && !$dirty) { + $TERM = 1; + } } - if (scalar(keys %to_build) == @done + @skipped + - scalar(keys %expansion_errors) && !$dirty) { - last; - } - - # No candidate packges and all thread works are idle, and pkgdeps - # is updated, in this case, set packages in %tmp_expansion_errors - # as real expansion_errors, and all packages depend on these packages - # can not be blocked. - if (@order == 0 && threads->list() == 0 && $dirty == 0) { - @expansion_errors{keys %tmp_expansion_errors} = values %tmp_expansion_errors; - } + last if ($TERM); if (@order == 0) { # Waiting thread workers done, then re-calculate ready packages