Skip to content

Commit

Permalink
fix #1494 socket read阻塞问题 (#1495)
Browse files Browse the repository at this point in the history
* fix #1494 socket read阻塞问题

* 优化readfunc

Co-authored-by: zixun <[email protected]>
  • Loading branch information
lvzixun and zixun committed Oct 29, 2021
1 parent 8f7e193 commit e35cad3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lualib/http/tlshelper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,16 @@ function tlshelper.closefunc(tls_ctx)
end

function tlshelper.readfunc(fd, tls_ctx)
local readfunc = socket.readfunc(fd)
local function readfunc()
readfunc = socket.readfunc(fd)
return ""
end
local read_buff = ""
return function (sz)
if not sz then
local s = ""
if #read_buff == 0 then
local ds = readfunc(sz)
local ds = readfunc()
s = tls_ctx:read(ds)
end
s = read_buff .. s
Expand Down

0 comments on commit e35cad3

Please sign in to comment.