Uploaded image for project: 'ZooKeeper'
  1. ZooKeeper
  2. ZOOKEEPER-2111

Not isAlive states should be synchronized in ClientCnxn

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.5.1, 3.6.0
    • Component/s: java client
    • Labels:
      None

      Description

      In ClientCnxn.queuePacket, it checks variables of state and closing and then make decisions. There is toctou race in queuePacket():

              if (!state.isAlive() || closing) {
                  conLossPacket(packet);
              } else {
                  ...
              }
      

      A possible race:
      in SendThread.run():

        while (state.isAlive()) {
          ...
        }
        cleanup();
      

      When it checks in queuePacket(), state is still alive. Then state isn't alive, SendThread.run() cleans up outgoingQueue. Then queuePacket adds packet to outgoingQueue. The packet should be waken up with exception. But it won't at this case.

        Attachments

        1. ZOOKEEPER-2111.patch
          5 kB
          Hongchao Deng
        2. ZOOKEEPER-2111.patch
          11 kB
          Hongchao Deng
        3. ZOOKEEPER-2111.patch
          2 kB
          Hongchao Deng
        4. ZOOKEEPER-2111.patch
          2 kB
          Rakesh R

          Activity

            People

            • Assignee:
              hdeng Hongchao Deng
              Reporter:
              hdeng Hongchao Deng
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: