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
80fb50ea
Commit
80fb50ea
authored
Oct 19, 2006
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code factorization
parent
e5ca059b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
51 deletions
+36
-51
configure.ac
configure.ac
+1
-0
src/network/io.c
src/network/io.c
+35
-51
No files found.
configure.ac
View file @
80fb50ea
...
@@ -772,6 +772,7 @@ fi # end "${SYS}" != "mingw32" -a "${SYS}" != "mingwce"
...
@@ -772,6 +772,7 @@ fi # end "${SYS}" != "mingw32" -a "${SYS}" != "mingwce"
AC_HEADER_TIME
AC_HEADER_TIME
AC_CHECK_TYPE(ssize_t, int)
AC_SEARCH_LIBS(poll, [poll], [AC_DEFINE(HAVE_POLL, 1, [Define to 1 if the OS is usabl... err, has poll().])])
AC_SEARCH_LIBS(poll, [poll], [AC_DEFINE(HAVE_POLL, 1, [Define to 1 if the OS is usabl... err, has poll().])])
dnl Check for dirent
dnl Check for dirent
...
...
src/network/io.c
View file @
80fb50ea
...
@@ -127,7 +127,7 @@ void net_Close (int fd)
...
@@ -127,7 +127,7 @@ void net_Close (int fd)
}
}
static
in
t
static
ssize_
t
net_ReadInner
(
vlc_object_t
*
restrict
p_this
,
unsigned
fdc
,
const
int
*
fdv
,
net_ReadInner
(
vlc_object_t
*
restrict
p_this
,
unsigned
fdc
,
const
int
*
fdv
,
const
v_socket_t
*
const
*
restrict
vsv
,
const
v_socket_t
*
const
*
restrict
vsv
,
uint8_t
*
restrict
p_buf
,
size_t
i_buflen
,
uint8_t
*
restrict
p_buf
,
size_t
i_buflen
,
...
@@ -135,10 +135,10 @@ net_ReadInner( vlc_object_t *restrict p_this, unsigned fdc, const int *fdv,
...
@@ -135,10 +135,10 @@ net_ReadInner( vlc_object_t *restrict p_this, unsigned fdc, const int *fdv,
{
{
size_t
i_total
=
0
;
size_t
i_total
=
0
;
do
while
(
i_buflen
>
0
)
{
{
unsigned
i
nt
i
;
unsigned
i
;
int
n
,
delay_ms
;
ssize_t
n
;
#ifdef HAVE_POLL
#ifdef HAVE_POLL
struct
pollfd
ufd
[
fdc
];
struct
pollfd
ufd
[
fdc
];
#else
#else
...
@@ -146,21 +146,18 @@ net_ReadInner( vlc_object_t *restrict p_this, unsigned fdc, const int *fdv,
...
@@ -146,21 +146,18 @@ net_ReadInner( vlc_object_t *restrict p_this, unsigned fdc, const int *fdv,
fd_set
set
;
fd_set
set
;
#endif
#endif
if
(
i_buflen
==
0
)
int
delay_ms
=
500
;
return
i_total
;
// output buffer full
if
((
wait_ms
!=
-
1
)
&&
(
wait_ms
<
500
))
delay_ms
=
500
;
if
(
(
wait_ms
!=
-
1
)
&&
(
wait_ms
<
500
)
)
delay_ms
=
wait_ms
;
delay_ms
=
wait_ms
;
if
(
p_this
->
b_die
)
if
(
p_this
->
b_die
)
{
{
errno
=
EINTR
;
errno
=
EINTR
;
goto
error
;
goto
error
;
}
}
#ifdef HAVE_POLL
#ifdef HAVE_POLL
memset
(
ufd
,
0
,
sizeof
(
ufd
)
);
memset
(
ufd
,
0
,
sizeof
(
ufd
)
);
for
(
i
=
0
;
i
<
fdc
;
i
++
)
for
(
i
=
0
;
i
<
fdc
;
i
++
)
{
{
...
@@ -169,25 +166,6 @@ net_ReadInner( vlc_object_t *restrict p_this, unsigned fdc, const int *fdv,
...
@@ -169,25 +166,6 @@ net_ReadInner( vlc_object_t *restrict p_this, unsigned fdc, const int *fdv,
}
}
n
=
poll
(
ufd
,
fdc
,
delay_ms
);
n
=
poll
(
ufd
,
fdc
,
delay_ms
);
if
(
n
==
-
1
)
goto
error
;
assert
(
(
unsigned
int
)
n
<=
fdc
);
for
(
i
=
0
;
n
>
0
;
i
++
)
{
if
(
(
i_total
>
0
)
&&
(
ufd
[
i
].
revents
&
POLLERR
)
)
return
i_total
;
// error will be dequeued on next run
if
(
ufd
[
i
].
revents
)
{
fdc
=
1
;
fdv
+=
i
;
vsv
+=
i
;
n
--
;
goto
receive
;
}
}
#else
#else
FD_ZERO
(
&
set
);
FD_ZERO
(
&
set
);
...
@@ -209,23 +187,32 @@ net_ReadInner( vlc_object_t *restrict p_this, unsigned fdc, const int *fdv,
...
@@ -209,23 +187,32 @@ net_ReadInner( vlc_object_t *restrict p_this, unsigned fdc, const int *fdv,
n
=
select
(
maxfd
+
1
,
&
set
,
NULL
,
NULL
,
n
=
select
(
maxfd
+
1
,
&
set
,
NULL
,
NULL
,
(
wait_ms
==
-
1
)
?
NULL
(
wait_ms
==
-
1
)
?
NULL
:
&
(
struct
timeval
){
0
,
delay_ms
*
1000
}
);
:
&
(
struct
timeval
){
0
,
delay_ms
*
1000
}
);
#endif
if
(
n
==
-
1
)
if
(
n
==
-
1
)
goto
error
;
goto
error
;
for
(
i
=
0
;
n
>
0
;
i
++
)
assert
((
unsigned
)
n
<=
fdc
);
if
(
FD_ISSET
(
fdv
[
i
],
&
set
)
)
if
(
n
==
0
)
// timeout
continue
;
for
(
i
=
0
;;
i
++
)
{
{
#ifdef HAVE_POLL
if
((
i_total
>
0
)
&&
(
ufd
[
i
].
revents
&
POLLERR
))
return
i_total
;
// error will be dequeued on next run
if
((
ufd
[
i
].
revents
&
POLLIN
)
==
0
)
#else
if
(
!
FD_ISSET
(
fdv
[
i
],
&
set
))
continue
;
#endif
fdc
=
1
;
fdc
=
1
;
fdv
+=
i
;
fdv
+=
i
;
vsv
+=
i
;
vsv
+=
i
;
n
--
;
break
;
goto
receive
;
}
}
#endif
continue
;
receive:
if
(
(
*
vsv
)
!=
NULL
)
if
(
(
*
vsv
)
!=
NULL
)
{
{
n
=
(
*
vsv
)
->
pf_recv
(
(
*
vsv
)
->
p_sys
,
p_buf
,
i_buflen
);
n
=
(
*
vsv
)
->
pf_recv
(
(
*
vsv
)
->
p_sys
,
p_buf
,
i_buflen
);
...
@@ -272,19 +259,16 @@ receive:
...
@@ -272,19 +259,16 @@ receive:
p_buf
+=
n
;
p_buf
+=
n
;
i_buflen
-=
n
;
i_buflen
-=
n
;
if
(
wait_ms
==
-
1
)
if
(
!
waitall
)
{
if
(
!
waitall
)
return
i_total
;
return
i_total
;
}
else
if
(
wait_ms
!=
-
1
)
{
{
wait_ms
-=
delay_ms
;
wait_ms
-=
delay_ms
;
if
(
wait_ms
==
0
)
return
i_total
;
// time's up!
}
}
}
}
while
(
wait_ms
);
return
i_total
;
// timeout
error:
error:
msg_Err
(
p_this
,
"Read error: %s"
,
net_strerror
(
net_errno
)
);
msg_Err
(
p_this
,
"Read error: %s"
,
net_strerror
(
net_errno
)
);
...
...
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