Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Steve Lhomme
VLC
Commits
8241e584
Commit
8241e584
authored
Dec 20, 2009
by
Antoine Cellerier
Committed by
Antoine Cellerier
Dec 21, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix blocking/non-blocking accept in lua interface.
parent
c77b28e2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
1 deletion
+36
-1
modules/misc/lua/intf.c
modules/misc/lua/intf.c
+2
-0
modules/misc/lua/libs/net.c
modules/misc/lua/libs/net.c
+34
-1
No files found.
modules/misc/lua/intf.c
View file @
8241e584
...
...
@@ -298,6 +298,8 @@ 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
;
vlc_cancel
(
p_sys
->
thread
);
if
(
!
p_sys
->
exiting
)
/* <- Read-only here and in thread: no locking */
{
vlc_mutex_lock
(
&
p_sys
->
lock
);
...
...
modules/misc/lua/libs/net.c
View file @
8241e584
...
...
@@ -39,6 +39,10 @@
#include <lua.h>
/* Low level lua C API */
#include <lauxlib.h>
/* Higher level C API */
#ifdef HAVE_POLL
#include <poll.h>
/* poll structures and defines */
#endif
#include "../vlc.h"
#include "../libs.h"
...
...
@@ -121,7 +125,36 @@ static int vlclua_net_accept( lua_State *L )
{
vlc_object_t
*
p_this
=
vlclua_get_this
(
L
);
int
**
ppi_fd
=
(
int
**
)
luaL_checkudata
(
L
,
1
,
"net_listen"
);
int
i_fd
=
net_Accept
(
p_this
,
*
ppi_fd
);
int
*
pi_fd
=
*
ppi_fd
;
int
i_timeout
=
luaL_optint
(
L
,
2
,
-
1
);
/* block is default */
/* Implement net_Accept with timeout */
int
i_fd
=
-
1
;
unsigned
int
i_count
=
1
;
while
(
pi_fd
[
0
][
i_count
]
!=
-
1
)
i_count
++
;
struct
pollfd
ufd
[
i_count
+
1
];
unsigned
int
i
;
for
(
i
=
0
;
i
<
i_count
;
i
++
)
{
ufd
[
i
].
fd
=
pi_fd
[
i
];
ufd
[
i
].
events
=
POLLIN
;
}
if
(
poll
(
ufd
,
i_count
,
i_timeout
)
>
0
)
{
for
(
i
=
0
;
i
<
i_count
;
i
++
)
{
if
(
!
ufd
[
i
].
revents
)
continue
;
i_fd
=
net_AcceptSingle
(
p_this
,
ufd
[
i
].
fd
);
if
(
i_fd
==
-
1
)
continue
;
memmove
(
pi_fd
+
i
,
pi_fd
+
i
+
1
,
i_count
-
(
i
+
1
)
);
pi_fd
[
i_count
-
1
]
=
ufd
[
i
].
fd
;
}
}
lua_pushinteger
(
L
,
i_fd
);
return
1
;
}
...
...
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