You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zookeeper.apache.org by nkalmar <gi...@git.apache.org> on 2018/12/03 09:31:34 UTC

[GitHub] zookeeper pull request #724: ZOOKEEPER-2488: Synchronized access to shutting...

Github user nkalmar commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/724#discussion_r238194209
  
    --- Diff: zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/QuorumPeer.java ---
    @@ -1162,10 +1162,12 @@ public void run() {
                             };
                             try {
                                 roZkMgr.start();
    -                            reconfigFlagClear();
    -                            if (shuttingDownLE) {
    -                                shuttingDownLE = false;
    -                                startLeaderElection();
    +                            synchronized (this) {
    +                                reconfigFlagClear();
    +                                if (shuttingDownLE) {
    --- End diff --
    
    Wouldn't it make more sense to make shuttingDownLE AtomicBoolean and use compareAndSet() here? The two methods (reconfigFlagClear and startLeaderElection) is already synchronized anyway, and only synchronized blocks access shuttingDownLE.
    
    What do you think?


---