ZooKeeper
  1. ZooKeeper
  2. ZOOKEEPER-1110

c interface zookeeper_close close fd too quickly.

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Invalid
    • Affects Version/s: 3.3.3
    • Fix Version/s: None
    • Component/s: c client
    • Labels:
      None
    • Environment:

      linux platform.

      Description

      The correct step about close client is the client send CLOSE_OP to the server, wait for several seconds, the server will process the terminal request and close the fd.
      But the zookeeper_close interface is wrong, because the adaptor_send_queue(zh, 3000) (line 2332), will first wait the timeout then send the request.
      The right order is first send the request then wait the timeout. I change as follow:
      $svn diff src/c/src/zookeeper.c
      Index: src/c/src/zookeeper.c
      ===================================================================
      — src/c/src/zookeeper.c (revision 1140451)
      +++ src/c/src/zookeeper.c (working copy)
      @@ -2329,7 +2329,8 @@

      /* make sure the close request is sent; we set timeout to an arbitrary

      • (but reasonable) number of milliseconds since we want the call to block*/
      • rc=adaptor_send_queue(zh, 3000);
        + rc=adaptor_send_queue(zh, 0);
        + sleep(3);
        }else{
        LOG_INFO(("Freeing zookeeper resources for sessionId=%#llx\n",
        zh->client_id.client_id));

        Activity

        Hide
        Tang Xi Liu added a comment -

        please do as you wish.

        Show
        Tang Xi Liu added a comment - please do as you wish.
        Hide
        Michi Mutsuzaki added a comment -

        Hi xiliu,

        Sorry it took this long to respond!

        I don't think this is a valid bug. The intention of the original code is to wait for the fd to become writable for a given amount of time, which I think is the right thing to do. This patch will make zookeeper_close() nonblocking; if the fd is not writable, it'll simply return ZOK without actually sending the request. That's not what we want to do.

        Let me know if I misunderstood your bug report. Otherwise, I'll close this ticket as invalid.

        Thanks!
        --Michi

        Show
        Michi Mutsuzaki added a comment - Hi xiliu, Sorry it took this long to respond! I don't think this is a valid bug. The intention of the original code is to wait for the fd to become writable for a given amount of time, which I think is the right thing to do. This patch will make zookeeper_close() nonblocking; if the fd is not writable, it'll simply return ZOK without actually sending the request. That's not what we want to do. Let me know if I misunderstood your bug report. Otherwise, I'll close this ticket as invalid. Thanks! --Michi

          People

          • Assignee:
            Unassigned
            Reporter:
            xiliu
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 0.5h
              0.5h
              Remaining:
              Remaining Estimate - 0.5h
              0.5h
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development