Skip to content

Commit 875bef0

Browse files
authored
fix: we don't need to close http_cli after reading chunks failed (#167)
It will be closed by watchcancel method. Signed-off-by: spacewander <[email protected]>
1 parent dcbed53 commit 875bef0

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ jobs:
3737
- name: setup go
3838
uses: actions/[email protected]
3939
with:
40-
go-version: "1.15"
40+
# goreman requires 1.17
41+
go-version: "1.17"
4142

4243
- name: get dependencies
4344
run: sudo apt install -y cpanminus build-essential libncurses5-dev libreadline-dev libssl-dev perl

lib/resty/etcd/v3.lua

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,6 @@ local function request_chunk(self, method, path, opts, timeout)
732732
while(1) do
733733
local chunk, read_err = res.body_reader()
734734
if read_err then
735-
http_cli:close()
736735
return nil, read_err
737736
end
738737
if not chunk then
@@ -760,21 +759,18 @@ local function request_chunk(self, method, path, opts, timeout)
760759

761760
local chunks, split_err = split(body, [[\n]], "jo")
762761
if split_err then
763-
http_cli:close()
764762
return nil, "failed to split chunks: " .. split_err
765763
end
766764

767765
local all_events = {}
768766
for _, chunk in ipairs(chunks) do
769767
body, err = decode_json(chunk)
770768
if not body then
771-
http_cli:close()
772769
return nil, "failed to decode json body: " .. (err or " unknown")
773770
elseif body.error and body.error.http_code >= 500 then
774771
-- health_check retry should do nothing here
775772
-- and let connection closed to create a new one
776773
health_check.report_failure(endpoint.http_host)
777-
http_cli:close()
778774
return nil, endpoint.http_host .. ": " .. body.error.http_status
779775
end
780776

0 commit comments

Comments
 (0)