Browse Source

ZOOKEEPER-1105 c client zookeeper_close not send CLOSE_OP request to server (lincoln.lee via michim)

git-svn-id: https://svn.apache.org/repos/asf/zookeeper/trunk@1380931 13f79535-47bb-0310-9956-ffa450edef68
Michi Mutsuzaki 12 years ago
parent
commit
5a1a34c731
2 changed files with 19 additions and 0 deletions
  1. 3 0
      CHANGES.txt
  2. 16 0
      src/c/src/zookeeper.c

+ 3 - 0
CHANGES.txt

@@ -234,6 +234,9 @@ BUGFIXES:
   ZOOKEEPER-1328. Misplaced assertion for the test case 'FLELostMessageTest'
   and not identifying misfunctions. (Rakesh R via mahadev)
 
+  ZOOKEEPER-1105 c client zookeeper_close not send CLOSE_OP request to server
+  (lincoln.lee via michim)
+
 IMPROVEMENTS:
 
   ZOOKEEPER-1170. Fix compiler (eclipse) warnings: unused imports,

+ 16 - 0
src/c/src/zookeeper.c

@@ -2519,6 +2519,22 @@ int zookeeper_close(zhandle_t *zh)
         /* 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);
+
+        /* make sure server has read the close request and sent back a response*/ 
+        struct pollfd fd_s[1];
+        fd_s[0].fd = zh->fd;
+        fd_s[0].events = POLLIN;
+        int ret = poll(fd_s, 1, 1000);
+        if (ret == 0) {
+            LOG_WARN(("Timeout when waitting for server's reply after sending a close request, sessionId=%#llx\n",
+                zh->client_id.client_id));
+        } else if (ret < 0) {
+            LOG_WARN(("System error happens when waitting for server's reply, sessionId=%#llx\n",
+                zh->client_id.client_id));
+        } else {
+            // do nothing
+        }
+
     }else{
         LOG_INFO(("Freeing zookeeper resources for sessionId=%#llx\n",
                 zh->client_id.client_id));