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
4b865c66
Commit
4b865c66
authored
Jun 30, 2015
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
network: use vlc_write_i11e() in net_Write() and simplify
parent
a3a6a95a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
54 deletions
+21
-54
src/network/io.c
src/network/io.c
+21
-54
No files found.
src/network/io.c
View file @
4b865c66
...
...
@@ -48,6 +48,7 @@
#endif
#include <vlc_network.h>
#include <vlc_interrupt.h>
#ifndef INADDR_ANY
# define INADDR_ANY 0x00000000
...
...
@@ -337,7 +338,6 @@ error:
return
-
1
;
}
#undef net_Write
/**
* Writes data to a socket.
* This blocks until all data is written or an error occurs.
...
...
@@ -347,73 +347,40 @@ error:
* @return the total number of bytes written, or -1 if an error occurs
* before any data is written.
*/
ssize_t
net_Write
(
vlc_object_t
*
p_this
,
int
fd
,
const
void
*
restrict
p_data
,
size_t
i_data
)
ssize_t
(
net_Write
)(
vlc_object_t
*
obj
,
int
fd
,
const
void
*
buf
,
size_t
len
)
{
size_t
i_total
=
0
;
struct
pollfd
ufd
[
2
]
=
{
{
.
fd
=
fd
,
.
events
=
POLLOUT
},
{
.
fd
=
vlc_object_waitpipe
(
p_this
),
.
events
=
POLLIN
},
};
if
(
unlikely
(
ufd
[
1
].
fd
==
-
1
))
{
vlc_testcancel
();
return
-
1
;
}
while
(
i_data
>
0
)
{
ufd
[
0
].
revents
=
ufd
[
1
].
revents
=
0
;
size_t
written
=
0
;
if
(
poll
(
ufd
,
sizeof
(
ufd
)
/
sizeof
(
ufd
[
0
]),
-
1
)
==
-
1
)
{
if
(
errno
==
EINTR
)
continue
;
msg_Err
(
p_this
,
"Polling error: %s"
,
vlc_strerror_c
(
errno
));
return
-
1
;
}
if
(
i_total
>
0
)
{
/* If POLLHUP resp. POLLERR|POLLNVAL occurs while we have already
* read some data, it is important that we first return the number
* of bytes read, and then return 0 resp. -1 on the NEXT call. */
if
(
ufd
[
0
].
revents
&
(
POLLHUP
|
POLLERR
|
POLLNVAL
))
break
;
if
(
ufd
[
1
].
revents
)
/* VLC object signaled */
break
;
}
else
do
{
if
(
ufd
[
1
].
revents
)
if
(
!
vlc_object_alive
(
obj
)
)
{
vlc_testcancel
();
errno
=
EINTR
;
goto
error
;
}
return
-
1
;
}
ssize_t
val
=
send
(
fd
,
p_data
,
i_data
,
MSG_NOSIGNAL
);
ssize_t
val
=
vlc_send_i11e
(
fd
,
buf
,
len
,
MSG_NOSIGNAL
);
if
(
val
==
-
1
)
{
if
(
errno
==
EINTR
)
if
(
errno
==
EINTR
||
errno
==
EAGAIN
)
continue
;
msg_Err
(
p_this
,
"Write error: %s"
,
vlc_strerror_c
(
errno
));
break
;
}
p_data
=
(
const
char
*
)
p_data
+
val
;
i_data
-=
val
;
i_total
+=
val
;
msg_Err
(
obj
,
"write error: %s"
,
vlc_strerror_c
(
errno
));
return
written
?
(
ssize_t
)
written
:
-
1
;
}
if
(
unlikely
(
i_data
==
0
)
)
vlc_testcancel
();
/* corner case */
if
(
val
==
0
)
break
;
if
((
i_total
>
0
)
||
(
i_data
==
0
))
return
i_total
;
written
+=
val
;
assert
(
len
>=
(
size_t
)
val
);
len
-=
val
;
buf
=
((
const
char
*
)
buf
)
+
val
;
}
while
(
len
>
0
);
error:
return
-
1
;
return
written
;
}
#undef net_Gets
...
...
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