]> git.tuebingen.mpg.de Git - paraslash.git/commit
audiod: Clean up fd closing logic in command handlers.
authorAndre Noll <maan@tuebingen.mpg.de>
Tue, 13 Jan 2015 22:53:28 +0000 (23:53 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Wed, 12 Aug 2015 21:23:47 +0000 (23:23 +0200)
commitc781b528c69927871c62cff33e94c87ce251bde9
tree6d3ce68e4b5b6830d8600f0279934fbbd936a5a3
parent16c6fc10f3344e3eec66e51580821d854d49aa62
audiod: Clean up fd closing logic in command handlers.

audiod_command.c contains this comment:

/*
 * command handlers don't close their fd on errors (ret < 0) so that
 * its caller can send an error message. Otherwise (ret >= 0) it's up
 * to each individual command to close the fd if necessary.
 */

This is a somewhat weird rule and this commit gets rid of it. Instead,
from now on the command handlers must not close their file descriptor
and handle_connect() closes it unconditionally.

The grab and stat commands need special treatment, which was the reason
for imposing the above rule. They need to keep the file descriptor open
to send the status items or the grabbed stream to the client. This
patch makes these two handlers create a copy of the descriptor with
dup(2). The new approach is simpler and less error-prone.
audiod_command.c
grab_client.c