]> git.sesse.net Git - vlc/commitdiff
LUA: hide EINTR from scripts and remove the timeout feature
authorRémi Denis-Courmont <remi@remlab.net>
Sun, 23 Jan 2011 15:40:50 +0000 (17:40 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Sun, 23 Jan 2011 15:49:00 +0000 (17:49 +0200)
Timeout makes it too easy to write crappy code.
It's also much easier to handle EINTR without timeout.

This fixes a minor bug: revents was undefined if poll() failed.

modules/misc/lua/libs/net.c
share/lua/README.txt
share/lua/intf/modules/host.lua

index ea635eecf8dc1db4b1c2089e18db18d011ebf92a..c4696b318d26ebd30ad1fd3e29cb48eb37bc056d 100644 (file)
@@ -201,7 +201,6 @@ static int vlclua_net_recv( lua_State *L )
 static int vlclua_net_poll( lua_State *L )
 {
     luaL_checktype( L, 1, LUA_TTABLE );
-    double f_timeout = luaL_optnumber( L, 2, -1. );
 
     int i_fds = 0;
     lua_pushnil( L );
@@ -223,7 +222,11 @@ static int vlclua_net_poll( lua_State *L )
         i++;
     }
 
-    int i_ret = poll( p_fds, i_fds, f_timeout < 0. ? -1 : (int)(f_timeout*1000) );
+    int i_ret;
+    do
+        i_ret = poll( p_fds, i_fds, -1 );
+    while( i_ret == -1 );
+
     for( i = 0; i < i_fds; i++ )
     {
         lua_pushinteger( L, p_fds[i].fd );
index edc917a8e780139ee828151d9b6f49ce5eff8cc1..3fa5cdb35b4e2315ea632634b2a29f5383fa2e7f 100644 (file)
@@ -199,7 +199,7 @@ net.connect_tcp( host, port ): open a connection to the given host:port (TCP).
 net.close( fd ): Close file descriptor.
 net.send( fd, string, [length] ): Send data on fd.
 net.recv( fd, [max length] ): Receive data from fd.
-net.poll( { fd = events }, [timeout in seconds] ): Implement poll function.
+net.poll( { fd = events } ): Implement poll function.
   Returns the numbers of file descriptors with a non 0 revent. The function
   modifies the input table to { fd = revents }. See "man poll".
 net.POLLIN/POLLPRI/POLLOUT/POLLRDHUP/POLLERR/POLLHUP/POLLNVAL: poll event flags
index 65eb993164676d1b10cfed995ca7407c750decdc..7d0c4040a5cbfcdcef4b8d81fc5ddf8231998eca 100644 (file)
@@ -244,7 +244,7 @@ function host()
             end
         end
 
-        local ret = vlc.net.poll( pollfds, timeout or -1 )
+        local ret = vlc.net.poll( pollfds )
         local wclients = {}
         local rclients = {}
         if ret > 0 then