Hi, this time, I have attempted to test everything, but I am sure Avuton will find many bugs again...
So this is a rather large refactoring of the command execution code. It changes the code from passing a raw file descriptor to passing a pointer to the client structure. Eric said he liked to keep the file descriptor, because he can use fdprintf() to write both to a client and to a file, but that flexibility is faked by a hack within fdprintf() which has to look up the client structure, and it doesn't work with buffered files (e.g. a standard FILE*), and the current code has to hack its way around that limitation. There are only two places where this flexibility is really needed: a) saving playlist, and the same code shows the playlist to the client b) saving the tag cache, and the same code shows song information to the client The code parts are very small, in fact only a few lines, and it isn't worth it to maintain this fdprintf() hack in return. My point is: the file descriptor is an internal value of the client structure, and should not be used outside. The client.c code does a lot of work to maintain buffers and to do asynchronous writing; nobody else should ever see the file descriptor. If the fd is only there to identify the client: why not use the pointer? That's what this patch set does. The compiled binary is about 5% larger now, but I expect that a lot more optimizations are possible now, and in the end, we will get a binary which is even smaller than before. As usual, get it from git: http://repo.or.cz/w/mpd-mk.git git://repo.or.cz/mpd-mk.git git://git.musicpd.org/cirrus/mpd.git/ Max Max Kellermann (35): include cleanup client: added client_write() and client_puts() client: added client_printf() tag: moved code to tag_print.c song: moved code to song_print.c, song_save.c tag: added buffered versions of the tag_print.c code playlist: added is_valid_playlist_name() playlist: replaced run-time check with assertion playlist: fix FILE* leak in appendSongToStoredPlaylistByPath() playlist: moved "repeat" and "random" value checks to command.c playlist: showPlaylist() and shufflePlaylist() cannot fail playlist: don't pass "fd" to playlist.c functions playlist: don't pass "fd" to storedPlaylist.c functions playlist: PlaylistInfo() does not call commandError() directory: don't pass fd to traverseAllIn() callbacks directory: don't pass fd to traverseAllIn() directory: printDirectoryInfo() does not call commandError() directory: don't pass "fd" to updateInit() volume: don't pass "fd" to changeVolumeLevel() audio: don't pass "fd" to {en,dis}ableAudioDevice() command: added command_success() and command_error() command: pass struct client to getCommandEntryAnd...() command: pass struct client to all commands pass "struct client" to dbUtils.c, song.c, tag_print.c playlist: pass struct client to loadPlaylist() command: removed commandError() command: concatenate strings at compile time tag: don't pass "fd" to printVisitedInTagTracker() ls: don't pass "fd" to lsPlaylists(), printRemoteUrlHandlers() playlist: added playlist_save() playlist: don't pass "fd" to showPlaylist(), playlistChangesPosId() stats: don't pass "fd" to printStats() audio: don't pass "fd" to printAudioDevices() client: removed client_get_fd() removed fdprintf() and client_print() b/src/Makefile.am | 11 b/src/audio.c | 33 -- b/src/audio.h | 10 b/src/client.c | 123 +++---- b/src/client.h | 24 + b/src/command.c | 792 ++++++++++++++++++++++++++++++++----------------- b/src/command.h | 5 b/src/dbUtils.c | 170 ++++++---- b/src/dbUtils.h | 27 - b/src/directory.c | 69 +--- b/src/directory.h | 15 b/src/locate.c | 1 b/src/log.c | 1 b/src/ls.c | 12 b/src/ls.h | 6 b/src/player_control.c | 2 b/src/playlist.c | 361 +++++++++------------- b/src/playlist.h | 74 ++-- b/src/song.c | 172 ---------- b/src/song.h | 20 - b/src/song_print.c | 54 +++ b/src/song_print.h | 30 + b/src/song_save.c | 177 ++++++++++ b/src/song_save.h | 29 + b/src/stats.c | 28 + b/src/stats.h | 4 b/src/storedPlaylist.c | 164 ++++------ b/src/storedPlaylist.h | 19 - b/src/tag.c | 27 - b/src/tag.h | 4 b/src/tagTracker.c | 15 b/src/tagTracker.h | 4 b/src/tag_internal.h | 24 + b/src/tag_print.c | 48 ++ b/src/tag_print.h | 29 + b/src/tag_save.c | 35 ++ b/src/tag_save.h | 28 + b/src/volume.c | 26 - b/src/volume.h | 2 src/myfprintf.c | 63 --- src/myfprintf.h | 28 - 41 files changed, 1577 insertions(+), 1189 deletions(-) ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Musicpd-dev-team mailing list Musicpd-dev-team@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team