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
d6a7bc11
Commit
d6a7bc11
authored
Jun 30, 2015
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
network: read more than one byte per recv() call
This reduces the system call overhead.
parent
27bb0783
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
13 deletions
+23
-13
src/network/io.c
src/network/io.c
+23
-13
No files found.
src/network/io.c
View file @
d6a7bc11
...
...
@@ -336,37 +336,47 @@ ssize_t (net_Write)(vlc_object_t *obj, int fd, const void *buf, size_t len)
char
*
net_Gets
(
vlc_object_t
*
obj
,
int
fd
)
{
char
*
buf
=
NULL
;
size_t
bufsize
=
0
,
buf
len
=
0
;
size_t
size
=
0
,
len
=
0
;
for
(;;)
{
if
(
buflen
==
buf
size
)
if
(
len
==
size
)
{
if
(
unlikely
(
bufsize
>=
(
1
<<
16
)))
if
(
unlikely
(
size
>=
(
1
<<
16
)))
{
errno
=
EMSGSIZE
;
goto
error
;
/* put sane buffer size limit */
}
char
*
newbuf
=
realloc
(
buf
,
buf
size
+
1024
);
char
*
newbuf
=
realloc
(
buf
,
size
+
1024
);
if
(
unlikely
(
newbuf
==
NULL
))
goto
error
;
buf
=
newbuf
;
buf
size
+=
1024
;
size
+=
1024
;
}
assert
(
len
<
size
);
ssize_t
val
=
net_Read
(
obj
,
fd
,
buf
+
buflen
,
1
);
if
(
val
<
1
)
ssize_t
val
=
vlc_recv_i11e
(
fd
,
buf
+
len
,
size
-
len
,
MSG_PEEK
);
if
(
val
<
=
0
)
goto
error
;
if
(
buf
[
buflen
]
==
'\n'
)
char
*
end
=
memchr
(
buf
+
len
,
'\n'
,
val
);
if
(
end
!=
NULL
)
val
=
(
end
+
1
)
-
(
buf
+
len
);
if
(
recv
(
fd
,
buf
+
len
,
val
,
0
)
!=
val
)
goto
error
;
len
+=
val
;
if
(
end
!=
NULL
)
break
;
buflen
++
;
}
buf
[
buflen
]
=
'\0'
;
if
(
buflen
>
0
&&
buf
[
buflen
-
1
]
==
'\r'
)
buf
[
buflen
-
1
]
=
'\0'
;
assert
(
len
>
0
);
buf
[
--
len
]
=
'\0'
;
if
(
len
>
0
&&
buf
[
--
len
]
==
'\r'
)
buf
[
len
]
=
'\0'
;
return
buf
;
error:
msg_Err
(
obj
,
"read error: %s"
,
vlc_strerror_c
(
errno
));
free
(
buf
);
return
NULL
;
}
...
...
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