Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
4f61cd0b
Commit
4f61cd0b
authored
5 years ago
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
client/Response: add constant MAX_BINARY_SIZE
Use the same chunk size for all binary commands.
parent
989790e7
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
3 deletions
+6
-3
Response.cxx
src/client/Response.cxx
+2
-0
Response.hxx
src/client/Response.hxx
+2
-0
FileCommands.cxx
src/command/FileCommands.cxx
+2
-3
No files found.
src/client/Response.cxx
View file @
4f61cd0b
...
...
@@ -59,6 +59,8 @@ Response::Format(const char *fmt, ...) noexcept
bool
Response
::
WriteBinary
(
ConstBuffer
<
void
>
payload
)
noexcept
{
assert
(
payload
.
size
<=
MAX_BINARY_SIZE
);
return
Format
(
"binary: %zu
\n
"
,
payload
.
size
)
&&
Write
(
payload
.
data
,
payload
.
size
)
&&
Write
(
"
\n
"
);
...
...
This diff is collapsed.
Click to expand it.
src/client/Response.hxx
View file @
4f61cd0b
...
...
@@ -77,6 +77,8 @@ public:
bool
FormatV
(
const
char
*
fmt
,
va_list
args
)
noexcept
;
bool
Format
(
const
char
*
fmt
,
...)
noexcept
;
static
constexpr
size_t
MAX_BINARY_SIZE
=
8192
;
/**
* Write a binary chunk; this writes the "binary" line, the
* given chunk and the trailing newline.
...
...
This diff is collapsed.
Click to expand it.
src/command/FileCommands.cxx
View file @
4f61cd0b
...
...
@@ -286,14 +286,13 @@ read_stream_art(Response &r, const char *uri, size_t offset)
const
offset_type
art_file_size
=
is
->
GetSize
();
constexpr
size_t
CHUNK_SIZE
=
8192
;
uint8_t
buffer
[
CHUNK_SIZE
];
uint8_t
buffer
[
Response
::
MAX_BINARY_SIZE
];
size_t
read_size
;
{
std
::
unique_lock
<
Mutex
>
lock
(
mutex
);
is
->
Seek
(
lock
,
offset
);
read_size
=
is
->
Read
(
lock
,
&
buffer
,
CHUNK_SIZE
);
read_size
=
is
->
Read
(
lock
,
&
buffer
,
sizeof
(
buffer
)
);
}
r
.
Format
(
"size: %"
PRIoffset
"
\n
"
,
art_file_size
);
...
...
This diff is collapsed.
Click to expand it.
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