From d2c7813156033f186d10370f0d1dfe06603fba92 Mon Sep 17 00:00:00 2001 From: "tim@chromium.org" Date: Wed, 14 Apr 2010 22:25:44 +0000 Subject: Land http://codereview.chromium.org/1621010 My first chrome patch :) -- Data race on boole in chrome/browser/sync/engine/syncer.cc Fix uses Lock class to avoid any compiler/hardware optimizations. BUG=37408 TEST=Ran Valgrind/ThreadSanitizer Original Patch by raz@chromium.org http://codereview.chromium.org/1621010 Review URL: http://codereview.chromium.org/1518023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44558 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/sync/engine/syncer.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'chrome') diff --git a/chrome/browser/sync/engine/syncer.h b/chrome/browser/sync/engine/syncer.h index e6be6d2..b387c7d 100644 --- a/chrome/browser/sync/engine/syncer.h +++ b/chrome/browser/sync/engine/syncer.h @@ -10,6 +10,7 @@ #include #include "base/basictypes.h" +#include "base/lock.h" #include "base/scoped_ptr.h" #include "chrome/browser/sync/engine/conflict_resolver.h" #include "chrome/browser/sync/engine/syncer_types.h" @@ -79,8 +80,14 @@ class Syncer { // Called by other threads to tell the syncer to stop what it's doing // and return early from SyncShare, if possible. - bool ExitRequested() { return early_exit_requested_; } - void RequestEarlyExit() { early_exit_requested_ = true; } + bool ExitRequested() { + AutoLock lock(early_exit_requested_lock_); + return early_exit_requested_; + } + void RequestEarlyExit() { + AutoLock lock(early_exit_requested_lock_); + early_exit_requested_ = true; + } // SyncShare(...) variants cause one sync cycle to occur. The return value // indicates whether we should sync again. If we should not sync again, @@ -139,6 +146,7 @@ class Syncer { SyncerStep last_step); bool early_exit_requested_; + Lock early_exit_requested_lock_; int32 max_commit_batch_size_; -- cgit v1.1