This forces Lua RC to exit cleanly in all cases.
luaopen_dialog( L, p_ext );
luaopen_input( L );
luaopen_msg( L );
luaopen_dialog( L, p_ext );
luaopen_input( L );
luaopen_msg( L );
luaopen_object( L );
luaopen_osd( L );
luaopen_playlist( L );
luaopen_object( L );
luaopen_osd( L );
luaopen_playlist( L );
#include <vlc_common.h>
#include <vlc_interface.h>
#include <vlc_common.h>
#include <vlc_interface.h>
#include "vlc.h"
#include "libs.h"
#include "vlc.h"
#include "libs.h"
+ if( vlc_pipe( p_sys->fd ) )
+ {
+ lua_close( p_sys->L );
+ goto error;
+ }
+
if( vlc_clone( &p_sys->thread, Run, p_intf, VLC_THREAD_PRIORITY_LOW ) )
{
if( vlc_clone( &p_sys->thread, Run, p_intf, VLC_THREAD_PRIORITY_LOW ) )
{
+ close( p_sys->fd[1] );
+ close( p_sys->fd[0] );
lua_close( p_sys->L );
goto error;
}
lua_close( p_sys->L );
goto error;
}
intf_thread_t *p_intf = (intf_thread_t*)p_this;
intf_sys_t *p_sys = p_intf->p_sys;
intf_thread_t *p_intf = (intf_thread_t*)p_this;
intf_sys_t *p_sys = p_intf->p_sys;
vlc_join( p_sys->thread, NULL );
vlc_join( p_sys->thread, NULL );
+ lua_close( p_sys->L );
+ close( p_sys->fd[0] );
free( p_sys->psz_filename );
free( p_sys );
}
free( p_sys->psz_filename );
free( p_sys );
}
#include <vlc_network.h>
#include <vlc_url.h>
#include <vlc_fs.h>
#include <vlc_network.h>
#include <vlc_url.h>
#include <vlc_fs.h>
+#include <vlc_interface.h>
#include "../vlc.h"
#include "../libs.h"
#include "../vlc.h"
#include "../libs.h"
/* Takes a { fd : events } table as first arg and modifies it to { fd : revents } */
static int vlclua_net_poll( lua_State *L )
{
/* Takes a { fd : events } table as first arg and modifies it to { fd : revents } */
static int vlclua_net_poll( lua_State *L )
{
+ intf_thread_t *intf = (intf_thread_t *)vlclua_get_this( L );
+ intf_sys_t *sys = intf->p_sys;
+
luaL_checktype( L, 1, LUA_TTABLE );
luaL_checktype( L, 1, LUA_TTABLE );
lua_pushnil( L );
while( lua_next( L, 1 ) )
{
i_fds++;
lua_pop( L, 1 );
}
lua_pushnil( L );
while( lua_next( L, 1 ) )
{
i_fds++;
lua_pop( L, 1 );
}
- struct pollfd *p_fds = malloc( i_fds * sizeof( struct pollfd ) );
- vlc_cleanup_push( free, p_fds );
+
+ struct pollfd *p_fds = xmalloc( i_fds * sizeof( *p_fds ) );
+
+ int i = 1;
+ p_fds[0].fd = sys->fd[0];
+ p_fds[0].events = POLLIN;
while( lua_next( L, 1 ) )
{
p_fds[i].fd = luaL_checkinteger( L, -2 );
while( lua_next( L, 1 ) )
{
p_fds[i].fd = luaL_checkinteger( L, -2 );
i_ret = poll( p_fds, i_fds, -1 );
while( i_ret == -1 && errno == EINTR );
i_ret = poll( p_fds, i_fds, -1 );
while( i_ret == -1 && errno == EINTR );
- for( i = 0; i < i_fds; i++ )
+ for( i = 1; i < i_fds; i++ )
{
lua_pushinteger( L, p_fds[i].fd );
lua_pushinteger( L, p_fds[i].revents );
lua_settable( L, 1 );
}
lua_pushinteger( L, i_ret );
{
lua_pushinteger( L, p_fds[i].fd );
lua_pushinteger( L, p_fds[i].revents );
lua_settable( L, 1 );
}
lua_pushinteger( L, i_ret );
- vlc_cleanup_run();
- return 1;
+
+ if( p_fds[0].revents )
+ i_ret = luaL_error( L, "Interrupted." );
+ else
+ i_ret = 1;
+ free( p_fds );
+
+ return i_ret;
}
/*****************************************************************************
}
/*****************************************************************************
luaL_register( L, "vlc", p_reg );
luaopen_input( L );
luaopen_msg( L );
luaL_register( L, "vlc", p_reg );
luaopen_input( L );
luaopen_msg( L );
luaopen_object( L );
luaopen_sd( L );
luaopen_strings( L );
luaopen_object( L );
luaopen_sd( L );
luaopen_strings( L );
{
char *psz_filename;
lua_State *L;
{
char *psz_filename;
lua_State *L;
+----------------------------------------------------------------
+/!\ NB: this namespace is ONLY usable for interfaces.
+---
+----------------------------------------------------------------
net.url_parse( url, [option delimiter] ): Parse URL. Returns a table with
fields "protocol", "username", "password", "host", "port", path" and
"option".
net.url_parse( url, [option delimiter] ): Parse URL. Returns a table with
fields "protocol", "username", "password", "host", "port", path" and
"option".