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
ea6dc345
Commit
ea6dc345
authored
Feb 11, 2012
by
Antoine Cellerier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove select timeout.
console and socket mode are now exclusive on windows.
parent
e0092fc5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
55 deletions
+48
-55
modules/lua/libs/net.c
modules/lua/libs/net.c
+1
-2
share/lua/README.txt
share/lua/README.txt
+1
-1
share/lua/intf/modules/host.lua
share/lua/intf/modules/host.lua
+46
-52
No files found.
modules/lua/libs/net.c
View file @
ea6dc345
...
@@ -215,11 +215,10 @@ static int vlclua_net_poll( lua_State *L )
...
@@ -215,11 +215,10 @@ static int vlclua_net_poll( lua_State *L )
lua_pop
(
L
,
1
);
lua_pop
(
L
,
1
);
i
++
;
i
++
;
}
}
int
i_timeout
=
luaL_optint
(
L
,
2
,
-
1
);
int
i_ret
;
int
i_ret
;
do
do
i_ret
=
poll
(
p_fds
,
i_fds
,
i_timeout
);
i_ret
=
poll
(
p_fds
,
i_fds
,
-
1
);
while
(
i_ret
==
-
1
);
while
(
i_ret
==
-
1
);
for
(
i
=
0
;
i
<
i_fds
;
i
++
)
for
(
i
=
0
;
i
<
i_fds
;
i
++
)
...
...
share/lua/README.txt
View file @
ea6dc345
...
@@ -191,7 +191,7 @@ net.connect_tcp( host, port ): open a connection to the given host:port (TCP).
...
@@ -191,7 +191,7 @@ net.connect_tcp( host, port ): open a connection to the given host:port (TCP).
net.close( fd ): Close file descriptor.
net.close( fd ): Close file descriptor.
net.send( fd, string, [length] ): Send data on fd.
net.send( fd, string, [length] ): Send data on fd.
net.recv( fd, [max length] ): Receive data from fd.
net.recv( fd, [max length] ): Receive data from fd.
net.poll( { fd = events }
, [timeout in ms]
): Implement poll function.
net.poll( { fd = events } ): Implement poll function.
Returns the numbers of file descriptors with a non 0 revent. The function
Returns the numbers of file descriptors with a non 0 revent. The function
modifies the input table to { fd = revents }. See "man poll".
modifies the input table to { fd = revents }. See "man poll".
net.POLLIN/POLLPRI/POLLOUT/POLLRDHUP/POLLERR/POLLHUP/POLLNVAL: poll event flags
net.POLLIN/POLLPRI/POLLOUT/POLLRDHUP/POLLERR/POLLHUP/POLLNVAL: poll event flags
...
...
share/lua/intf/modules/host.lua
View file @
ea6dc345
...
@@ -122,11 +122,7 @@ function host()
...
@@ -122,11 +122,7 @@ function host()
local
function
read_console
(
client
,
len
)
local
function
read_console
(
client
,
len
)
-- Read stdin from a windows console (beware: select/poll doesn't work!)
-- Read stdin from a windows console (beware: select/poll doesn't work!)
if
vlc
.
win
.
console_wait
(
0
)
then
return
vlc
.
win
.
console_read
()
return
vlc
.
win
.
console_read
()
else
return
0
end
end
end
local
function
del_client
(
client
)
local
function
del_client
(
client
)
...
@@ -208,6 +204,9 @@ function host()
...
@@ -208,6 +204,9 @@ function host()
and
listeners
.
tcp
[
host
][
port
]
then
and
listeners
.
tcp
[
host
][
port
]
then
error
(
"Already listening on tcp host `"
..
host
..
":"
..
tostring
(
port
)
..
"'"
)
error
(
"Already listening on tcp host `"
..
host
..
":"
..
tostring
(
port
)
..
"'"
)
end
end
if
listeners
.
stdio
and
vlc
.
win
then
error
(
"Cannot listen on console and sockets concurrently on Windows"
)
end
if
not
listeners
.
tcp
then
if
not
listeners
.
tcp
then
listeners
.
tcp
=
{}
listeners
.
tcp
=
{}
end
end
...
@@ -230,6 +229,9 @@ function host()
...
@@ -230,6 +229,9 @@ function host()
if
listeners
.
stdio
then
if
listeners
.
stdio
then
error
(
"Already listening on stdio"
)
error
(
"Already listening on stdio"
)
end
end
if
listeners
.
tcp
and
vlc
.
win
then
error
(
"Cannot listen on console and sockets concurrently on Windows"
)
end
new_client
(
h
,
0
,
1
,
client_type
.
stdio
)
new_client
(
h
,
0
,
1
,
client_type
.
stdio
)
listeners
.
stdio
=
true
listeners
.
stdio
=
true
end
end
...
@@ -250,63 +252,56 @@ function host()
...
@@ -250,63 +252,56 @@ function host()
end
end
end
end
local
function
_accept_and_select
(
h
,
timeout
)
local
function
_accept_and_select
(
h
)
local
function
filter_client
(
fds
,
status
,
event
)
for
_
,
client
in
pairs
(
clients
)
do
if
client
.
status
==
status
then
fds
[
client
:
fd
()]
=
event
end
end
end
local
pollfds
=
{}
filter_client
(
pollfds
,
status
.
read
,
vlc
.
net
.
POLLIN
)
filter_client
(
pollfds
,
status
.
password
,
vlc
.
net
.
POLLIN
)
filter_client
(
pollfds
,
status
.
write
,
vlc
.
net
.
POLLOUT
)
if
listeners
.
tcp
then
for
_
,
listener
in
pairs
(
listeners
.
tcp
.
list
)
do
for
_
,
fd
in
pairs
({
listener
.
data
:
fds
()})
do
pollfds
[
fd
]
=
vlc
.
net
.
POLLIN
end
end
end
local
timeout
=
-
1
if
vlc
.
win
and
listeners
.
stdio
then
timeout
=
50
end
local
ret
=
0
if
not
vlc
.
win
or
listeners
.
tcp
then
ret
=
vlc
.
net
.
poll
(
pollfds
,
timeout
)
end
local
wclients
=
{}
local
wclients
=
{}
local
rclients
=
{}
local
rclients
=
{}
if
ret
>
0
then
if
not
(
vlc
.
win
and
listeners
.
stdio
)
then
for
_
,
client
in
pairs
(
clients
)
do
local
function
filter_client
(
fds
,
status
,
event
)
if
is_flag_set
(
pollfds
[
client
:
fd
()],
vlc
.
net
.
POLLERR
)
for
_
,
client
in
pairs
(
clients
)
do
or
is_flag_set
(
pollfds
[
client
:
fd
()],
vlc
.
net
.
POLLHUP
)
if
client
.
status
==
status
then
or
is_flag_set
(
pollfds
[
client
:
fd
()],
vlc
.
net
.
POLLNVAL
)
then
fds
[
client
:
fd
()]
=
event
del_client
(
client
)
end
elseif
is_flag_set
(
pollfds
[
client
:
fd
()],
vlc
.
net
.
POLLOUT
)
then
table.insert
(
wclients
,
client
)
elseif
is_flag_set
(
pollfds
[
client
:
fd
()],
vlc
.
net
.
POLLIN
)
then
table.insert
(
rclients
,
client
)
end
end
end
end
local
pollfds
=
{}
filter_client
(
pollfds
,
status
.
read
,
vlc
.
net
.
POLLIN
)
filter_client
(
pollfds
,
status
.
password
,
vlc
.
net
.
POLLIN
)
filter_client
(
pollfds
,
status
.
write
,
vlc
.
net
.
POLLOUT
)
if
listeners
.
tcp
then
if
listeners
.
tcp
then
for
_
,
listener
in
pairs
(
listeners
.
tcp
.
list
)
do
for
_
,
listener
in
pairs
(
listeners
.
tcp
.
list
)
do
for
_
,
fd
in
pairs
({
listener
.
data
:
fds
()})
do
for
_
,
fd
in
pairs
({
listener
.
data
:
fds
()})
do
if
is_flag_set
(
pollfds
[
fd
],
vlc
.
net
.
POLLIN
)
then
pollfds
[
fd
]
=
vlc
.
net
.
POLLIN
local
afd
=
listener
.
data
:
accept
()
new_client
(
h
,
afd
,
afd
,
listener
.
type
)
break
end
end
end
end
end
end
end
end
if
vlc
.
win
and
listeners
.
stdio
then
local
ret
=
vlc
.
net
.
poll
(
pollfds
)
if
ret
>
0
then
for
_
,
client
in
pairs
(
clients
)
do
if
is_flag_set
(
pollfds
[
client
:
fd
()],
vlc
.
net
.
POLLERR
)
or
is_flag_set
(
pollfds
[
client
:
fd
()],
vlc
.
net
.
POLLHUP
)
or
is_flag_set
(
pollfds
[
client
:
fd
()],
vlc
.
net
.
POLLNVAL
)
then
del_client
(
client
)
elseif
is_flag_set
(
pollfds
[
client
:
fd
()],
vlc
.
net
.
POLLOUT
)
then
table.insert
(
wclients
,
client
)
elseif
is_flag_set
(
pollfds
[
client
:
fd
()],
vlc
.
net
.
POLLIN
)
then
table.insert
(
rclients
,
client
)
end
end
if
listeners
.
tcp
then
for
_
,
listener
in
pairs
(
listeners
.
tcp
.
list
)
do
for
_
,
fd
in
pairs
({
listener
.
data
:
fds
()})
do
if
is_flag_set
(
pollfds
[
fd
],
vlc
.
net
.
POLLIN
)
then
local
afd
=
listener
.
data
:
accept
()
new_client
(
h
,
afd
,
afd
,
listener
.
type
)
break
end
end
end
end
end
else
for
_
,
client
in
pairs
(
clients
)
do
for
_
,
client
in
pairs
(
clients
)
do
if
client
.
type
==
client_type
.
stdio
then
if
client
.
type
==
client_type
.
stdio
then
if
client
.
status
==
status
.
read
or
client
.
status
==
status
.
password
then
if
client
.
status
==
status
.
read
or
client
.
status
==
status
.
password
then
...
@@ -319,7 +314,6 @@ function host()
...
@@ -319,7 +314,6 @@ function host()
end
end
end
end
end
end
return
wclients
,
rclients
return
wclients
,
rclients
end
end
...
...
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