Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
2e68de72
Commit
2e68de72
authored
Jun 20, 2013
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lua: raise an erro from net.poll() when quitting
This forces Lua RC to exit cleanly in all cases.
parent
80fc185b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
37 additions
and
10 deletions
+37
-10
modules/lua/extension.c
modules/lua/extension.c
+0
-1
modules/lua/intf.c
modules/lua/intf.c
+12
-1
modules/lua/libs/net.c
modules/lua/libs/net.c
+20
-7
modules/lua/services_discovery.c
modules/lua/services_discovery.c
+0
-1
modules/lua/vlc.h
modules/lua/vlc.h
+1
-0
share/lua/README.txt
share/lua/README.txt
+4
-0
No files found.
modules/lua/extension.c
View file @
2e68de72
...
...
@@ -821,7 +821,6 @@ static lua_State* GetLuaState( extensions_manager_t *p_mgr,
luaopen_dialog
(
L
,
p_ext
);
luaopen_input
(
L
);
luaopen_msg
(
L
);
luaopen_net
(
L
);
luaopen_object
(
L
);
luaopen_osd
(
L
);
luaopen_playlist
(
L
);
...
...
modules/lua/intf.c
View file @
2e68de72
...
...
@@ -33,6 +33,7 @@
#include <vlc_common.h>
#include <vlc_interface.h>
#include <vlc_fs.h>
#include "vlc.h"
#include "libs.h"
...
...
@@ -360,8 +361,16 @@ static int Start_LuaIntf( vlc_object_t *p_this, const char *name )
p_sys
->
L
=
L
;
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
)
)
{
close
(
p_sys
->
fd
[
1
]
);
close
(
p_sys
->
fd
[
0
]
);
lua_close
(
p_sys
->
L
);
goto
error
;
}
...
...
@@ -380,9 +389,11 @@ void Close_LuaIntf( vlc_object_t *p_this )
intf_thread_t
*
p_intf
=
(
intf_thread_t
*
)
p_this
;
intf_sys_t
*
p_sys
=
p_intf
->
p_sys
;
close
(
p_sys
->
fd
[
1
]
);
vlc_join
(
p_sys
->
thread
,
NULL
);
lua_close
(
p_sys
->
L
);
lua_close
(
p_sys
->
L
);
close
(
p_sys
->
fd
[
0
]
);
free
(
p_sys
->
psz_filename
);
free
(
p_sys
);
}
...
...
modules/lua/libs/net.c
View file @
2e68de72
...
...
@@ -41,6 +41,7 @@
#include <vlc_network.h>
#include <vlc_url.h>
#include <vlc_fs.h>
#include <vlc_interface.h>
#include "../vlc.h"
#include "../libs.h"
...
...
@@ -194,19 +195,25 @@ static int vlclua_net_recv( 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
);
int
i_fds
=
0
;
int
i_fds
=
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
)
);
lua_pushnil
(
L
);
int
i
=
0
;
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
);
...
...
@@ -220,15 +227,21 @@ static int vlclua_net_poll( lua_State *L )
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
);
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
;
}
/*****************************************************************************
...
...
modules/lua/services_discovery.c
View file @
2e68de72
...
...
@@ -110,7 +110,6 @@ int Open_LuaSD( vlc_object_t *p_this )
luaL_register
(
L
,
"vlc"
,
p_reg
);
luaopen_input
(
L
);
luaopen_msg
(
L
);
luaopen_net
(
L
);
luaopen_object
(
L
);
luaopen_sd
(
L
);
luaopen_strings
(
L
);
...
...
modules/lua/vlc.h
View file @
2e68de72
...
...
@@ -158,6 +158,7 @@ struct intf_sys_t
{
char
*
psz_filename
;
lua_State
*
L
;
int
fd
[
2
];
vlc_thread_t
thread
;
};
...
...
share/lua/README.txt
View file @
2e68de72
...
...
@@ -159,6 +159,10 @@ misc.quit(): Quit VLC.
Net
---
----------------------------------------------------------------
/!\ 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".
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment