summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYonit Halperin <yhalperi@redhat.com>2013-07-25 15:07:43 -0400
committerYonit Halperin <yhalperi@redhat.com>2013-07-29 11:35:17 -0400
commit02f44c137df99ed2e89699e49b64c13673b0cd06 (patch)
treeec6d5fddd3ce6f0cdb6cda4dadfdc9345a2b6565
parent134b7f310de5120b233670d18641d32204f31318 (diff)
downloadspice-02f44c137df99ed2e89699e49b64c13673b0cd06.tar.gz
spice-02f44c137df99ed2e89699e49b64c13673b0cd06.tar.xz
spice-02f44c137df99ed2e89699e49b64c13673b0cd06.zip
snd_worker/snd_disconnect_channel: don't call snd_channel_put if the channel has already been disconnected
The snd channels has one reference as long as their socket is active. The playback channel has an additional reference for each frame that is currently filled by the sound device. Once the channel is disconnected (the socket has been freed and the first reference is released) snd_disconnect_channel shouldn't release a reference again.
-rw-r--r--server/snd_worker.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/server/snd_worker.c b/server/snd_worker.c
index 849f0026..3827416c 100644
--- a/server/snd_worker.c
+++ b/server/snd_worker.c
@@ -212,21 +212,20 @@ static void snd_disconnect_channel(SndChannel *channel)
{
SndWorker *worker;
- if (!channel) {
+ if (!channel || !channel->stream) {
spice_debug("not connected");
return;
}
spice_debug("%p", channel);
worker = channel->worker;
- if (channel->stream) {
- channel->cleanup(channel);
- red_channel_client_disconnect(worker->connection->channel_client);
- core->watch_remove(channel->stream->watch);
- channel->stream->watch = NULL;
- reds_stream_free(channel->stream);
- channel->stream = NULL;
- spice_marshaller_destroy(channel->send_data.marshaller);
- }
+ channel->cleanup(channel);
+ red_channel_client_disconnect(worker->connection->channel_client);
+ worker->connection->channel_client = NULL;
+ core->watch_remove(channel->stream->watch);
+ channel->stream->watch = NULL;
+ reds_stream_free(channel->stream);
+ channel->stream = NULL;
+ spice_marshaller_destroy(channel->send_data.marshaller);
snd_channel_put(channel);
worker->connection = NULL;
}
@@ -897,6 +896,7 @@ static SndChannel *__new_channel(SndWorker *worker, int size, uint32_t channel_i
int tos;
MainChannelClient *mcc = red_client_get_main(client);
+ spice_assert(stream);
if ((flags = fcntl(stream->socket, F_GETFL)) == -1) {
spice_printerr("accept failed, %s", strerror(errno));
goto error1;