gresolv: Add more debug prints
authorJukka Rissanen <jukka.rissanen@linux.intel.com>
Thu, 18 Oct 2012 11:35:16 +0000 (14:35 +0300)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Fri, 19 Oct 2012 07:26:13 +0000 (10:26 +0300)
gweb/gresolv.c

index 88e2c02978ca3baabf7c699cd6086aa4c53975f2..da09b2b21e3825dccf383a877c4302f259c40b29 100644 (file)
@@ -141,6 +141,8 @@ static void _debug(GResolv *resolv, const char *file, const char *caller,
 
 static void destroy_query(struct resolv_query *query)
 {
+       debug(query->resolv, "query %p timeout %d", query, query->timeout);
+
        if (query->timeout > 0)
                g_source_remove(query->timeout);
 
@@ -149,6 +151,9 @@ static void destroy_query(struct resolv_query *query)
 
 static void destroy_lookup(struct resolv_lookup *lookup)
 {
+       debug(lookup->resolv, "lookup %p id %d ipv4 %p ipv6 %p",
+               lookup, lookup->id, lookup->ipv4_query, lookup->ipv6_query);
+
        if (lookup->ipv4_query != NULL) {
                g_queue_remove(lookup->resolv->query_queue,
                                                lookup->ipv4_query);
@@ -505,6 +510,8 @@ static void sort_and_return_results(struct resolv_lookup *lookup)
                        status = lookup->ipv4_status;
        }
 
+       debug(lookup->resolv, "lookup %p received %d results", lookup, n);
+
        g_queue_remove(lookup->resolv->lookup_queue, lookup);
 
        lookup->result_func(status, results, lookup->result_data);
@@ -882,11 +889,15 @@ void g_resolv_unref(GResolv *resolv)
        if (__sync_fetch_and_sub(&resolv->ref_count, 1) != 1)
                return;
 
-       while ((lookup = g_queue_pop_head(resolv->lookup_queue)))
+       while ((lookup = g_queue_pop_head(resolv->lookup_queue))) {
+               debug(resolv, "lookup %p id %d", lookup, lookup->id);
                destroy_lookup(lookup);
+       }
 
-       while ((query = g_queue_pop_head(resolv->query_queue)))
+       while ((query = g_queue_pop_head(resolv->query_queue))) {
+               debug(resolv, "query %p", query);
                destroy_query(query);
+       }
 
        g_queue_free(resolv->query_queue);
        g_queue_free(resolv->lookup_queue);
@@ -960,6 +971,8 @@ static gint add_query(struct resolv_lookup *lookup, const char *hostname, int ty
 
        query->msgid = buf[0] << 8 | buf[1];
 
+       debug(lookup->resolv, "sending %d bytes", len);
+
        if (send_query(lookup->resolv, buf, len) < 0) {
                g_free(query);
                return -EIO;
@@ -970,6 +983,9 @@ static gint add_query(struct resolv_lookup *lookup, const char *hostname, int ty
 
        g_queue_push_tail(lookup->resolv->query_queue, query);
 
+       debug(lookup->resolv, "lookup %p id %d query %p", lookup, lookup->id,
+                                                                       query);
+
        query->timeout = g_timeout_add_seconds(5, query_timeout, query);
 
        if (type == ns_t_aaaa)
@@ -985,7 +1001,7 @@ guint g_resolv_lookup_hostname(GResolv *resolv, const char *hostname,
 {
        struct resolv_lookup *lookup;
 
-       debug(resolv, "lookup hostname %s", hostname);
+       debug(resolv, "hostname %s", hostname);
 
        if (resolv == NULL)
                return 0;
@@ -1045,21 +1061,31 @@ guint g_resolv_lookup_hostname(GResolv *resolv, const char *hostname,
        }
 
        g_queue_push_tail(resolv->lookup_queue, lookup);
+
+       debug(resolv, "lookup %p id %d", lookup, lookup->id);
+
        return lookup->id;
 }
 
 gboolean g_resolv_cancel_lookup(GResolv *resolv, guint id)
 {
+       struct resolv_lookup *lookup;
        GList *list;
 
+       debug(resolv, "lookup id %d", id);
+
        list = g_queue_find_custom(resolv->lookup_queue,
                                GUINT_TO_POINTER(id), compare_lookup_id);
 
        if (list == NULL)
                return FALSE;
 
-       g_queue_remove(resolv->lookup_queue, list->data);
-       destroy_lookup(list->data);
+       lookup = list->data;
+
+       debug(resolv, "lookup %p", lookup);
+
+       g_queue_remove(resolv->lookup_queue, lookup);
+       destroy_lookup(lookup);
 
        return TRUE;
 }