Blob Blame History Raw
From c2e46b926e0ee4226f0f93942e7fa2c5b409f73d Mon Sep 17 00:00:00 2001
From: Yonit Halperin <yhalperi@redhat.com>
Date: Fri, 26 Jul 2013 12:15:00 -0400
Subject: [PATCH 8/8] log: improve debug information related to client
 disconnection

---
 server/red_channel.c | 9 ++++++---
 server/snd_worker.c  | 7 ++++---
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/server/red_channel.c b/server/red_channel.c
index 9168b8a..d565634 100644
--- a/server/red_channel.c
+++ b/server/red_channel.c
@@ -1112,6 +1112,7 @@ static void red_channel_client_ref(RedChannelClient *rcc)
 static void red_channel_client_unref(RedChannelClient *rcc)
 {
     if (!--rcc->refs) {
+        spice_debug("destroy rcc=%p", rcc);
         if (rcc->send_data.main.marshaller) {
             spice_marshaller_destroy(rcc->send_data.main.marshaller);
         }
@@ -1708,6 +1709,8 @@ static void red_channel_client_disconnect_dummy(RedChannelClient *rcc)
 {
     spice_assert(rcc->dummy);
     if (ring_item_is_linked(&rcc->channel_link)) {
+        spice_printerr("rcc=%p (channel=%p type=%d id=%d)", rcc, rcc->channel,
+                       rcc->channel->type, rcc->channel->id);
         red_channel_remove_client(rcc);
     }
     rcc->dummy_connected = FALSE;
@@ -1715,8 +1718,6 @@ static void red_channel_client_disconnect_dummy(RedChannelClient *rcc)
 
 void red_channel_client_disconnect(RedChannelClient *rcc)
 {
-    spice_printerr("%p (channel %p type %d id %d)", rcc, rcc->channel,
-                                                rcc->channel->type, rcc->channel->id);
     if (rcc->dummy) {
         red_channel_client_disconnect_dummy(rcc);
         return;
@@ -1724,6 +1725,8 @@ void red_channel_client_disconnect(RedChannelClient *rcc)
     if (!red_channel_client_is_connected(rcc)) {
         return;
     }
+    spice_printerr("rcc=%p (channel=%p type=%d id=%d)", rcc, rcc->channel,
+                   rcc->channel->type, rcc->channel->id);
     red_channel_client_pipe_clear(rcc);
     if (rcc->stream->watch) {
         rcc->channel->core->watch_remove(rcc->stream->watch);
@@ -2007,7 +2010,7 @@ void red_client_destroy(RedClient *client)
     RingItem *link, *next;
     RedChannelClient *rcc;
 
-    spice_printerr("destroy client with #channels %d", client->channels_num);
+    spice_printerr("destroy client %p with #channels=%d", client, client->channels_num);
     if (!pthread_equal(pthread_self(), client->thread_id)) {
         spice_warning("client->thread_id (0x%lx) != pthread_self (0x%lx)."
                       "If one of the threads is != io-thread && != vcpu-thread,"
diff --git a/server/snd_worker.c b/server/snd_worker.c
index 3827416..ebddfcd 100644
--- a/server/snd_worker.c
+++ b/server/snd_worker.c
@@ -201,8 +201,8 @@ static SndChannel *snd_channel_get(SndChannel *channel)
 static SndChannel *snd_channel_put(SndChannel *channel)
 {
     if (!--channel->refs) {
+        spice_printerr("SndChannel=%p freed", channel);
         free(channel);
-        spice_printerr("sound channel freed");
         return NULL;
     }
     return channel;
@@ -216,7 +216,8 @@ static void snd_disconnect_channel(SndChannel *channel)
         spice_debug("not connected");
         return;
     }
-    spice_debug("%p", channel);
+    spice_debug("SndChannel=%p rcc=%p type=%d",
+                 channel, channel->channel_client, channel->channel_client->channel->type);
     worker = channel->worker;
     channel->cleanup(channel);
     red_channel_client_disconnect(worker->connection->channel_client);
@@ -976,11 +977,11 @@ static void snd_disconnect_channel_client(RedChannelClient *rcc)
 {
     SndWorker *worker;
 
-    spice_debug(NULL);
     spice_assert(rcc->channel);
     spice_assert(rcc->channel->data);
     worker = (SndWorker *)rcc->channel->data;
 
+    spice_debug("channel-type=%d", rcc->channel->type);
     if (worker->connection) {
         spice_assert(worker->connection->channel_client == rcc);
         snd_disconnect_channel(worker->connection);
-- 
1.8.3.1