Skip to content

Commit

Permalink
sync: optimistic write
Browse files Browse the repository at this point in the history
When flushing the output buffer, always assume that the socket is
writable.  Most of the time, it really is, and the select() is a waste
of time.  In case it is not, libmpdclient falls back to select().
  • Loading branch information
MaxKellermann committed Oct 28, 2009
1 parent 35470b1 commit 5ca813b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions NEWS
Expand Up @@ -3,6 +3,7 @@ libmpdclient 2.1 (2009/??/??)
* song: copy last_modified value in mpd_song_dup()
* socket, async: use WSAGetLastError() instead of errno on WIN32
* socket: connect in non-blocking mode
* sync: optimistic write, reduce select() calls
* Makefile.am: use --version-script only with GNU ld


Expand Down
3 changes: 3 additions & 0 deletions src/sync.c
Expand Up @@ -153,6 +153,9 @@ mpd_sync_flush(struct mpd_async *async, const struct timeval *tv0)
} else
tvp = NULL;

if (!mpd_async_io(async, MPD_ASYNC_EVENT_WRITE))
return false;

while (true) {
enum mpd_async_event events = mpd_async_events(async);
if ((events & MPD_ASYNC_EVENT_WRITE) == 0)
Expand Down

0 comments on commit 5ca813b

Please sign in to comment.