[vlc-devel] commit: Remove vlc.net.select() and fd_set. (Antoine Cellerier )

git version control git at videolan.org
Sat Jan 9 11:50:57 CET 2010


vlc | branch: master | Antoine Cellerier <dionoea at videolan.org> | Sat Jan  9 11:51:06 2010 +0100| [5ac9e88e16f22b8fb82adba43cfd89b5302f20bc] | committer: Antoine Cellerier 

Remove vlc.net.select() and fd_set.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5ac9e88e16f22b8fb82adba43cfd89b5302f20bc
---

 modules/misc/lua/libs/net.c |   94 -------------------------------------------
 share/lua/README.txt        |   10 +----
 2 files changed, 1 insertions(+), 103 deletions(-)

diff --git a/modules/misc/lua/libs/net.c b/modules/misc/lua/libs/net.c
index f577211..ebe5b78 100644
--- a/modules/misc/lua/libs/net.c
+++ b/modules/misc/lua/libs/net.c
@@ -216,98 +216,6 @@ static int vlclua_net_poll( lua_State *L )
     return 1;
 }
 
-static int vlclua_net_select( lua_State *L )
-{
-    int i_ret;
-    size_t i_nfds = luaL_checkint( L, 1 );
-    fd_set *fds_read = (fd_set*)luaL_checkudata( L, 2, "fd_set" );
-    fd_set *fds_write = (fd_set*)luaL_checkudata( L, 3, "fd_set" );
-    double f_timeout = luaL_checknumber( L, 4 );
-    struct timeval timeout;
-
-#ifndef WIN32
-    if( i_nfds > FD_SETSIZE )
-        i_nfds = FD_SETSIZE;
-#endif
-    if( f_timeout >= 0. )
-    {
-        timeout.tv_sec = (int)f_timeout;
-        timeout.tv_usec = (int)(1e6*(f_timeout-(double)((int)f_timeout)));
-    }
-    i_ret = select( i_nfds, fds_read, fds_write, 0, f_timeout >= 0. ? &timeout : NULL );
-    lua_pushinteger( L, i_ret );
-    return 1;
-}
-
-/*****************************************************************************
- *
- *****************************************************************************/
-static int vlclua_fd_clr( lua_State * );
-static int vlclua_fd_isset( lua_State * );
-static int vlclua_fd_set( lua_State * );
-static int vlclua_fd_zero( lua_State * );
-
-static const luaL_Reg vlclua_fd_set_reg[] = {
-    { "clr", vlclua_fd_clr },
-    { "isset", vlclua_fd_isset },
-    { "set", vlclua_fd_set },
-    { "zero", vlclua_fd_zero },
-    { NULL, NULL }
-};
-
-static int vlclua_fd_set_new( lua_State *L )
-{
-    fd_set *fds = (fd_set*)lua_newuserdata( L, sizeof( fd_set ) );
-    FD_ZERO( fds );
-
-    if( luaL_newmetatable( L, "fd_set" ) )
-    {
-        lua_newtable( L );
-        luaL_register( L, NULL, vlclua_fd_set_reg );
-        lua_setfield( L, -2, "__index" );
-    }
-
-    lua_setmetatable( L, -2 );
-    return 1;
-}
-
-static int vlclua_fd_clr( lua_State *L )
-{
-    fd_set *fds = (fd_set*)luaL_checkudata( L, 1, "fd_set" );
-    int i_fd = luaL_checkint( L, 2 );
-    FD_CLR( i_fd, fds );
-    return 0;
-}
-
-static int vlclua_fd_isset( lua_State *L )
-{
-    fd_set *fds = (fd_set*)luaL_checkudata( L, 1, "fd_set" );
-    int i_fd = luaL_checkint( L, 2 );
-    lua_pushboolean( L, FD_ISSET( i_fd, fds ) );
-    return 1;
-}
-
-static int vlclua_fd_set( lua_State *L )
-{
-    fd_set *fds = (fd_set*)luaL_checkudata( L, 1, "fd_set" );
-    size_t i_fd = luaL_checkint( L, 2 );
-    /* FIXME: we should really use poll() instead here, but that breaks the
-     * VLC/LUA API. On Windows, overflow protection is built-in FD_SET, not
-     * on POSIX. In both cases, run-time behavior will however be wrong. */
-#ifndef WIN32
-    if( i_fd < FD_SETSIZE )
-#endif
-        FD_SET( i_fd, fds );
-    return 0;
-}
-
-static int vlclua_fd_zero( lua_State *L )
-{
-    fd_set *fds = (fd_set*)luaL_checkudata( L, 1, "fd_set" );
-    FD_ZERO( fds );
-    return 0;
-}
-
 /*****************************************************************************
  *
  *****************************************************************************/
@@ -432,8 +340,6 @@ static const luaL_Reg vlclua_net_reg[] = {
     { "send", vlclua_net_send },
     { "recv", vlclua_net_recv },
     { "poll", vlclua_net_poll },
-    { "select", vlclua_net_select },
-    { "fd_set_new", vlclua_fd_set_new },
     { "read", vlclua_fd_read },
     { "write", vlclua_fd_write },
     { "stat", vlclua_stat }, /* Not really "net" */
diff --git a/share/lua/README.txt b/share/lua/README.txt
index 1257d4e..960ebab 100644
--- a/share/lua/README.txt
+++ b/share/lua/README.txt
@@ -114,7 +114,7 @@ net.url_parse( url, [option delimiter] ): Parse URL. Returns a table with
 net.listen_tcp( host, port ): Listen to TCP connections. This returns an
   object with an accept and an fds method. accept is blocking (Poll on the
   fds with the net.POLLIN flag if you want to be non blockin).
-  The fds method returns a list of fds you can call select on before using
+  The fds method returns a list of fds you can call poll on before using
   the accept method. For example:
 local l = vlc.net.listen_tcp( "localhost", 1234 )
 while true do
@@ -131,14 +131,6 @@ net.poll( { fd = events }, [timeout in seconds] ): Implement poll function.
   Retruns 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
-net.select( nfds, fds_read, fds_write, timeout ): Monitor a bunch of file
-  descriptors. Returns number of fds to handle. See "man select".
-net.fd_set_new(): Create a new fd_set.
-local fds = vlc.net.fd_set_new()
-fds:clr( fd ) -- remove fd from set
-fds:isset( fd ) -- check if fd is set
-fds:set( fd ) -- add fd to set
-fds:zero() -- clear the set
 net.fd_read( fd, [max length] ): Read data from fd.
 net.fd_write( fd, string, [length] ): Write data to fd.
 net.stat( path ): Stat a file. Returns a table with the following fields:




More information about the vlc-devel mailing list