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

ZK prime_connection(the Handshake) can complete without reading all the payload.

    XMLWordPrintableJSON

    Details

      Description

      /* returns:

      • -1 if recv call failed,
      • 0 if recv would block,
      • 1 if success

      */

      static int recv_buffer(zhandle_t *zh, buffer_list_t *buff)

      {

      int off = buff->curr_offset;

      int rc = 0;

      [................]

      if (buff == &zh->primer_buffer && rc == buff->len - 1) ++rc; <====== Handshake prematurely complete.

      On non-blocking socket, it's possible that socket has exactly "buff->len - 1" bytes to read.
      Because of the above line, the Handshake is prematurely completed.
      What this can lead to is:
      There will be one outstanding byte left on the socket and it might go as part of next message which could get corrupted.

      I think this can lead to ZRUNTIMEINCONSISTENCY issues later.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                ztzg Damien Diederen
                Reporter:
                suhas.dantkale Suhas Dantkale
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 10m
                  1h 10m