IIOD: Properly handle errors from iio_buffer_push

Previously, the clients were signaled before the call to
iio_buffer_push; so they were receiving a positive value (which means no
error) even if iio_buffer_push failed.

Furthermore, the mutex for the condition used to signal the threads was
not unlocked: having iio_buffer_push fail triggered a second signal
being sent, which resulted in a deadlock.

Now, the clients are signaled after the call to iio_buffer_push, so that
only one call is sent. The exception is when an error occurs while
reading the data from the client; in this case, the client might be
signaled twice, but only the first signal matters. The deadlock is
avoided by properly unlocking the condition lock after the signal is
received.

This also fixes a bug where the R/W thread would exit its endless loop
with the thread list lock unlocked upon failure of iio_buffer_push.

Signed-off-by: Paul Cercueil <paul.cercueil@analog.com>