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
85db2d67
Commit
85db2d67
authored
May 19, 2021
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/proxy: split search into chunks to avoid exceeding the output buffer
Closes
https://github.com/MusicPlayerDaemon/MPD/issues/1130
parent
22ebb2bd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
15 deletions
+38
-15
NEWS
NEWS
+1
-0
ProxyDatabasePlugin.cxx
src/db/plugins/ProxyDatabasePlugin.cxx
+37
-15
No files found.
NEWS
View file @
85db2d67
...
...
@@ -5,6 +5,7 @@ ver 0.23 (not yet released)
* database
- proxy: require MPD 0.20 or later
- proxy: require libmpdclient 2.11 or later
- proxy: split search into chunks to avoid exceeding the output buffer
* output
- pipewire: new plugin
- snapcast: new plugin
...
...
src/db/plugins/ProxyDatabasePlugin.cxx
View file @
85db2d67
...
...
@@ -825,26 +825,48 @@ try {
const
bool
exact
=
selection
.
filter
==
nullptr
||
!
selection
.
filter
->
HasFoldCase
();
if
(
!
mpd_search_db_songs
(
connection
,
exact
)
||
!
SendConstraints
(
connection
,
selection
,
selection
.
window
)
||
!
mpd_search_commit
(
connection
))
ThrowError
(
connection
);
/* request only this number of songs at a time to avoid
blowing the server's max_output_buffer_size limit */
constexpr
unsigned
LIMIT
=
4096
;
while
(
auto
*
song
=
mpd_recv_song
(
connection
))
{
AllocatedProxySong
song2
(
song
);
auto
remaining_window
=
selection
.
window
;
if
(
Match
(
selection
.
filter
,
song2
))
{
try
{
visit_song
(
song2
);
}
catch
(...)
{
mpd_response_finish
(
connection
);
throw
;
while
(
remaining_window
.
start
<
remaining_window
.
end
)
{
auto
window
=
remaining_window
;
if
(
window
.
end
-
window
.
start
>
LIMIT
)
window
.
end
=
window
.
start
+
LIMIT
;
if
(
!
mpd_search_db_songs
(
connection
,
exact
)
||
!
SendConstraints
(
connection
,
selection
,
window
)
||
!
mpd_search_commit
(
connection
))
ThrowError
(
connection
);
while
(
auto
*
song
=
mpd_recv_song
(
connection
))
{
++
window
.
start
;
AllocatedProxySong
song2
(
song
);
if
(
Match
(
selection
.
filter
,
song2
))
{
try
{
visit_song
(
song2
);
}
catch
(...)
{
mpd_response_finish
(
connection
);
throw
;
}
}
}
}
if
(
!
mpd_response_finish
(
connection
))
ThrowError
(
connection
);
if
(
!
mpd_response_finish
(
connection
))
ThrowError
(
connection
);
if
(
window
.
start
!=
window
.
end
)
/* the other MPD has given us less than we
requested - this means there's no more
data */
break
;
remaining_window
.
start
=
window
.
end
;
}
}
catch
(...)
{
if
(
connection
!=
nullptr
)
mpd_search_cancel
(
connection
);
...
...
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