Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
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-2-2
Commits
ecbbbc15
Commit
ecbbbc15
authored
Jan 05, 2008
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use the event pipe in net_Read instead of an arbitrary timer
parent
318d3056
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
15 deletions
+31
-15
src/network/io.c
src/network/io.c
+31
-15
No files found.
src/network/io.c
View file @
ecbbbc15
...
...
@@ -256,7 +256,7 @@ int *net_Listen (vlc_object_t *p_this, const char *psz_host,
/*****************************************************************************
* __net_Read:
*****************************************************************************
* Read
from a network socket
* Read
s from a network socket.
* If waitall is true, then we repeat until we have read the right amount of
* data; in that case, a short count means EOF has been reached.
*****************************************************************************/
...
...
@@ -265,14 +265,20 @@ __net_Read (vlc_object_t *restrict p_this, int fd, const v_socket_t *vs,
uint8_t
*
restrict
p_buf
,
size_t
i_buflen
,
vlc_bool_t
waitall
)
{
size_t
i_total
=
0
;
struct
pollfd
ufd
[
1
];
ufd
[
0
].
fd
=
fd
;
ufd
[
0
].
events
=
POLLIN
;
struct
pollfd
ufd
[
2
]
=
{
{
.
fd
=
fd
,
.
events
=
POLLIN
},
{
.
fd
=
-
1
,
.
events
=
POLLIN
},
};
msg_Dbg
(
p_this
,
"reading socket %d"
,
fd
);
vlc_object_lock
(
p_this
);
ufd
[
1
].
fd
=
vlc_object_waitpipe
(
p_this
);
while
(
i_buflen
>
0
)
{
if
(
(
p_this
->
b_die
)
||
(
p_this
->
p_libvlc
->
b_die
)
)
int
val
;
if
(
!
vlc_object_alive
(
p_this
))
{
#if defined(WIN32) || defined(UNDER_CE)
WSASetLastError
(
WSAEINTR
);
...
...
@@ -281,16 +287,21 @@ __net_Read (vlc_object_t *restrict p_this, int fd, const v_socket_t *vs,
#endif
goto
error
;
}
ufd
[
0
].
revents
=
ufd
[
1
].
revents
=
0
;
ufd
[
0
].
revents
=
0
;
/* TODO: don't use arbitrary timer just for b_die */
switch
(
poll
(
ufd
,
sizeof
(
ufd
)
/
sizeof
(
ufd
[
0
]),
500
))
{
case
-
1
:
goto
error
;
vlc_object_unlock
(
p_this
);
val
=
poll
(
ufd
,
sizeof
(
ufd
)
/
sizeof
(
ufd
[
0
]),
-
1
);
vlc_object_lock
(
p_this
);
case
0
:
// timeout
continue
;
if
(
val
<
0
)
goto
error
;
if
(
ufd
[
1
].
revents
)
{
msg_Dbg
(
p_this
,
"socket %d polling interrupted"
,
fd
);
vlc_object_wait
(
p_this
);
msg_Dbg
(
p_this
,
"socket %d polling restarting"
,
fd
);
continue
;
}
assert
(
ufd
[
0
].
revents
);
...
...
@@ -304,7 +315,7 @@ __net_Read (vlc_object_t *restrict p_this, int fd, const v_socket_t *vs,
* otherwise we'd "hide" the error from the caller, which is a
* bad idea™. */
if
(
ufd
[
0
].
revents
&
(
POLLERR
|
POLLNVAL
|
POLLRDHUP
))
return
i_total
;
break
;
}
ssize_t
n
;
...
...
@@ -367,11 +378,16 @@ __net_Read (vlc_object_t *restrict p_this, int fd, const v_socket_t *vs,
if
(
!
waitall
)
break
;
}
vlc_object_unlock
(
p_this
);
msg_Dbg
(
p_this
,
"read %u bytes from socket %d"
,
(
unsigned
)
i_total
,
fd
);
return
i_total
;
error:
msg_Err
(
p_this
,
"Read error: %m"
);
return
i_total
?
(
ssize_t
)
i_total
:
-
1
;
vlc_object_unlock
(
p_this
);
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