Skip to content

Commit 28656f3

Browse files
committed
http/h2_connection: fix busy-loop when waiting for preface
1 parent e79ad71 commit 28656f3

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

http/h2_connection.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,10 @@ function connection_methods:step(timeout)
233233
local deadline = timeout and monotime()+timeout
234234
if not self.has_confirmed_preface and self.type == "server" then
235235
local ok, err, errno = socket_has_preface(self.socket, false, timeout)
236+
self.had_eagain = false
236237
if ok == nil then
237238
if errno == ce.ETIMEDOUT then
239+
self.had_eagain = true
238240
return true
239241
end
240242
return nil, err, errno

spec/h2_connection_spec.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ describe("http2 connection", function()
5454
test_preface("PRI * HTTP/2.0\r\n\r\nSM\r\n\r") -- missing last \n
5555
test_preface(("long string"):rep(1000))
5656
end)
57+
it("Doesn't busy-loop looking for #preface", function()
58+
local s, c = ca.assert(cs.pair())
59+
s = assert(h2_connection.new(s, "server"))
60+
assert(s:step(0))
61+
assert.not_same(0, (s:timeout()))
62+
c:close()
63+
s:close()
64+
end)
5765
it("read_http2_frame fails with EILSEQ on corrupt frame", function()
5866
local spack = string.pack or require "compat53.string".pack -- luacheck: ignore 143
5967
local s, c = ca.assert(cs.pair())

0 commit comments

Comments
 (0)