lua:socket settimeout does not work

Bug #1441914 reported by Alex Athanasopoulos
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
luasocket (Ubuntu)
New
Undecided
Unassigned

Bug Description

Ubuntu Version: Ubuntu 14.04.2 LTS
package lua-socket:i386 3.0~rc1-3

On Ubuntu 14.04, lua socket settimeout does not work as expected. On a tcp socket, it causes the next receive to close the connection immediately.
It works correctly on Ubuntu 12.04 and debian 7.

To reproduce:
install packages lua5.1 and lua-socket
Take the echo server example from the introduction to luasocket:
http://w3.impa.br/~diego/software/luasocket/introduction.html
Put it in a file echo.lua and run it with "lua echo.lua"
From another window, use telnet localhost {port} to connect to the echo server
Result: Immediately after connecting, the server closes the connection.
Expected Result: The server should wait 10 seconds for input, then close the connection.

package version that works correctly in debian 7: lua-socket:i386 2.0.2-8

-------------
A copy of the example (echo.lua):

-- load namespace
local socket = require("socket")
-- create a TCP socket and bind it to the local host, at any port
local server = assert(socket.bind("*", 0))
-- find out which port the OS chose for us
local ip, port = server:getsockname()
-- print a message informing what's up
print("Please telnet to localhost on port " .. port)
print("After connecting, you have 10s to enter a line to be echoed")
-- loop forever waiting for clients
while 1 do
  -- wait for a connection from any client
  local client = server:accept()
  -- make sure we don't block waiting for this client's line
  client:settimeout(10)
  -- receive the line
  local line, err = client:receive()
  -- if there was no error, send it back to the client
  if not err then client:send(line .. "\n") end
  -- done with client, close the object
  client:close()
end

Revision history for this message
Alex Athanasopoulos (filopodaros) wrote :

It works correctly in Ubuntu 12.04, using packages:
liblua5.1-socket2 2.0.2-6
lua5.1

Revision history for this message
Alex Athanasopoulos (filopodaros) wrote :

It is also broken with lua5.2 (on ubuntu 14.04).

Stephen M. Webb (bregma)
affects: unity (Ubuntu) → luasocket (Ubuntu)
Revision history for this message
AnWilco (anwilco) wrote :

I'm experiencing this and I've tracked it down to an old bug in luasocket (in src/buffer.c) that was first introduced on 7th July 2011 and then fixed on 9th Sept 2013.

Hope this helps

Revision history for this message
Alex Athanasopoulos (filopodaros) wrote :

This works correctly on Ubuntu 16.04 with lua5.3 or lua5.2 + lua-socket
With lua5.3 I had to run with "lua5.3" instead of "lua"
It no longer affects me, since Ubuntu 16.04 is the latest LTS.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.