mirror of
https://github.com/lunarmodules/luasocket.git
synced 2025-07-13 06:04:31 +02:00
Crashy bug fixed in recvraw.
Also fixed returns on closed socket.
This commit is contained in:
@ -498,7 +498,63 @@ remote(string.format([[
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------
|
||||
|
||||
function test_readafterclose()
|
||||
local back, partial, err
|
||||
local str = 'little string'
|
||||
reconnect()
|
||||
pass("trying repeated '*a' pattern")
|
||||
remote (string.format ([[
|
||||
data:send('%s')
|
||||
data:close()
|
||||
data = nil
|
||||
]], str))
|
||||
back, err, partial = data:receive("*a")
|
||||
assert(back == str, "unexpected data read")
|
||||
back, err, partial = data:receive("*a")
|
||||
assert(back == nil and err == "closed", "should have returned 'closed'")
|
||||
print("ok")
|
||||
reconnect()
|
||||
pass("trying active close before '*a'")
|
||||
remote (string.format ([[
|
||||
data:close()
|
||||
data = nil
|
||||
]]))
|
||||
data:close()
|
||||
back, err, partial = data:receive("*a")
|
||||
assert(back == nil and err == "closed", "should have returned 'closed'")
|
||||
print("ok")
|
||||
reconnect()
|
||||
pass("trying active close before '*l'")
|
||||
remote (string.format ([[
|
||||
data:close()
|
||||
data = nil
|
||||
]]))
|
||||
data:close()
|
||||
back, err, partial = data:receive()
|
||||
assert(back == nil and err == "closed", "should have returned 'closed'")
|
||||
print("ok")
|
||||
reconnect()
|
||||
pass("trying active close before raw 1")
|
||||
remote (string.format ([[
|
||||
data:close()
|
||||
data = nil
|
||||
]]))
|
||||
data:close()
|
||||
back, err, partial = data:receive(1)
|
||||
assert(back == nil and err == "closed", "should have returned 'closed'")
|
||||
print("ok")
|
||||
reconnect()
|
||||
pass("trying active close before raw 0")
|
||||
remote (string.format ([[
|
||||
data:close()
|
||||
data = nil
|
||||
]]))
|
||||
data:close()
|
||||
back, err, partial = data:receive(0)
|
||||
assert(back == nil and err == "closed", "should have returned 'closed'")
|
||||
print("ok")
|
||||
os.exit()
|
||||
end
|
||||
|
||||
test("method registration")
|
||||
test_methods(socket.tcp(), {
|
||||
@ -541,6 +597,9 @@ test_methods(socket.udp(), {
|
||||
"settimeout"
|
||||
})
|
||||
|
||||
test("testing read after close")
|
||||
test_readafterclose()
|
||||
|
||||
test("select function")
|
||||
test_selectbugs()
|
||||
|
||||
|
Reference in New Issue
Block a user