浏览代码

ZOOKEEPER-1756. zookeeper_interest() in C client can return a timeval of 0 (Eric Lindvall via michim)

git-svn-id: https://svn.apache.org/repos/asf/zookeeper/trunk@1551366 13f79535-47bb-0310-9956-ffa450edef68
Michi Mutsuzaki 11 年之前
父节点
当前提交
5cb7ec496c
共有 2 个文件被更改,包括 12 次插入7 次删除
  1. 3 0
      CHANGES.txt
  2. 9 7
      src/c/src/zookeeper.c

+ 3 - 0
CHANGES.txt

@@ -501,6 +501,9 @@ BUGFIXES:
   ZOOKEEPER-1622. session ids will be negative in the year 2022
   (Eric Newton via phunt)
 
+  ZOOKEEPER-1756. zookeeper_interest() in C client can return a timeval of 0
+  (Eric Lindvall via michim)
+
 IMPROVEMENTS:
 
   ZOOKEEPER-1170. Fix compiler (eclipse) warnings: unused imports,

+ 9 - 7
src/c/src/zookeeper.c

@@ -2034,13 +2034,15 @@ int zookeeper_interest(zhandle_t *zh, int *fd, int *interest,
         // a PING
         if (zh->state==ZOO_CONNECTED_STATE) {
             send_to = zh->recv_timeout/3 - idle_send;
-            if (send_to <= 0 && zh->sent_requests.head==0) {
-//                LOG_DEBUG(LOGCALLBACK(zh), "Sending PING to %s (exceeded idle by %dms)",
-//                                zoo_get_current_server(zh),-send_to);
-                rc = send_ping(zh);
-                if (rc < 0){
-                    LOG_ERROR(LOGCALLBACK(zh), "failed to send PING request (zk retcode=%d)",rc);
-                    return api_epilog(zh,rc);
+            if (send_to <= 0) {
+                if (zh->sent_requests.head == 0) {
+//                  LOG_DEBUG(LOGCALLBACK(zh), "Sending PING to %s (exceeded idle by %dms)",
+//                            zoo_get_current_server(zh),-send_to);
+                    rc = send_ping(zh);
+                    if (rc < 0) {
+                        LOG_ERROR(LOGCALLBACK(zh), "failed to send PING request (zk retcode=%d)",rc);
+                        return api_epilog(zh,rc);
+                    }
                 }
                 send_to = zh->recv_timeout/3;
             }