lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Diego wrote:
> That said, the beta version already supports setting a
> timeout before calling connect and it works fine.

While we are at it: I noticed that Luasocket does not put accepted sockets
into non-blocking mode. Excerpt from the accept(2) man-page:

: [...] Note that any per file descriptor flags (everything that can be  set
: with  the F_SETFL fcntl, like non blocking or async state) are not
: inherited across an accept. [...]

Usually you never notice since Luasocket does a select() just before
every recv/send. But this is not sufficient. The syscall will block
if you are sending more data than the internal socket buffer can hold.

Patch against luasocket-2.0-alpha below.


*** tcp.c.orig	Sat Aug 16 02:14:15 2003
--- tcp.c	Sat Jun 19 08:22:59 2004
*** 214,219 ****
--- 214,220 ----
          } else break;
+     sock_setnonblocking(&client->sock);
      /* initialize remaining structure fields */
      io_init(&client->io, (p_send) sock_send, (p_recv) sock_recv, &client->sock);
      tm_init(&client->tm, -1, -1);