From issues-return-70-archive-asf-public=cust-asf.ponee.io@zookeeper.apache.org Sat Jun 8 01:32:02 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 5452518067E for ; Sat, 8 Jun 2019 03:32:02 +0200 (CEST) Received: (qmail 66608 invoked by uid 500); 8 Jun 2019 01:32:01 -0000 Mailing-List: contact issues-help@zookeeper.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zookeeper.apache.org Delivered-To: mailing list issues@zookeeper.apache.org Received: (qmail 66597 invoked by uid 99); 8 Jun 2019 01:32:01 -0000 Received: from mailrelay1-us-west.apache.org (HELO mailrelay1-us-west.apache.org) (209.188.14.139) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 08 Jun 2019 01:32:01 +0000 Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 42C5EE2CC5 for ; Sat, 8 Jun 2019 01:32:01 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id C9D372462F for ; Sat, 8 Jun 2019 01:32:00 +0000 (UTC) Date: Sat, 8 Jun 2019 01:32:00 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@zookeeper.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (ZOOKEEPER-3420) With newer ZK C Client and older ZK server, recv_buffer() could potentially return 0 continuously on non-blocking socket MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/ZOOKEEPER-3420?page=3Dcom.atla= ssian.jira.plugin.system.issuetabpanels:all-tabpanel ] ASF GitHub Bot updated ZOOKEEPER-3420: -------------------------------------- Labels: pull-request-available (was: ) > With newer ZK C Client and older ZK server, recv_buffer() could potential= ly return 0 continuously on non-blocking socket > -------------------------------------------------------------------------= ----------------------------------------------- > > Key: ZOOKEEPER-3420 > URL: https://issues.apache.org/jira/browse/ZOOKEEPER-3420 > Project: ZooKeeper > Issue Type: Bug > Components: c client > Affects Versions: 3.5.3 > Reporter: Suhas Dantkale > Priority: Major > Labels: pull-request-available > > With newer ZK C Client (3.5.*) and older ZK server(3.4.*), recv_buffer() = could potentially return 0 continuously on non-blocking socket. > Following in the recv_buffer() snippet:- > Here, should the check be: > if (buff =3D=3D &zh->primer_buffer && buff->curr_offset + rc =3D=3D buff-= >len + sizeof(buff->len) - 1) ++rc; > instead of > if (buff =3D=3D &zh->primer_buffer && rc =3D=3D buff->len - 1) ++rc; > snippet :- > =C2=A0 if (buff->buffer) { > /* want off to now represent the offset into the buffer */ > off -=3D sizeof(buff->len); > rc =3D recv(zh->fd, buff->buffer+off, buff->len-off, 0); > /* dirty hack to make new client work against old server > * old server sends 40 bytes to finish connection handshake, > * while we're expecting 41 (1 byte for read-only mode data) */ > if (buff =3D=3D &zh->primer_buffer && rc =3D=3D buff->len - 1) ++rc= ; <=3D=3D=3D=3D=3D=3D Problem Line(?) > switch(rc) { > case 0: > errno =3D EHOSTDOWN; > case -1: > #ifdef _WIN32 > if (WSAGetLastError() =3D=3D WSAEWOULDBLOCK) { > #else > if (errno =3D=3D EAGAIN) { > #endif > break; > } > return -1; > default: > buff->curr_offset +=3D rc; > } > } > return buff->curr_offset =3D=3D buff->len + sizeof(buff->len); > Probably the given code assumes that recv() operation will read in one go= . > But on non-blocking socket, that assumption doesn't hold true. -- This message was sent by Atlassian JIRA (v7.6.3#76005)