Skip to content

Commit ed94918

Browse files
committed
use ms instead of seconds to match poll
1 parent ecbc291 commit ed94918

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

ljsocket.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,11 +1286,11 @@ do
12861286

12871287
if key:lower() == "rcvtimeo" or key:lower() == "sndtimeo" then
12881288
if ffi.os == "Windows" then
1289-
val = ffi.new("int[1]", val * 1000)
1289+
val = ffi.new("int[1]", val)
12901290
else
12911291
local tv = timeval()
1292-
tv.tv_sec = math.floor(val)
1293-
tv.tv_usec = (val - math.floor(val)) * 1000000
1292+
tv.tv_sec = math.floor(val / 1000)
1293+
tv.tv_usec = (val % 1000) * 1000
12941294
val = tv
12951295
end
12961296
else

test/timeout_blocking.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ test('TCP client rcvtimeo timeout blocking test', function()
55
local sock = assert(socket.create("inet", "stream", "tcp"))
66
assert(sock:connect("httpbin.org", "http"))
77
assert(sock:send("GET /delay/10 HTTP/1.1\r\nHost: httpbin.org\r\n\r\n"))
8-
assert(sock:set_option("rcvtimeo", 0.25))
8+
assert(sock:set_option("rcvtimeo", 250))
99
local res, err = sock:receive()
1010
if res then
1111
error("expected timeout error, got data")
@@ -30,7 +30,7 @@ test('TCP client sndtimeo blocking test', function()
3030
local accepted = assert(server:accept())
3131

3232
-- Set a short send timeout
33-
assert(client:set_option("sndtimeo", 0.25))
33+
assert(client:set_option("sndtimeo", 250))
3434

3535
-- Try to send enough data to fill the send buffer
3636
-- This should eventually timeout when the buffer is full

0 commit comments

Comments
 (0)