Added cancel operation for asyncns resolver
authorMikael Hallendal <micke@imendio.com>
Fri, 01 Aug 2008 16:31:23 +0200
changeset 475 001da49d7fd1
parent 474 b4eff3e1235c
child 476 08d36982e998
Added cancel operation for asyncns resolver
loudmouth/lm-asyncns-resolver.c
loudmouth/lm-old-socket.c
loudmouth/lm-resolver.h
--- a/loudmouth/lm-asyncns-resolver.c	Fri Aug 01 15:48:25 2008 +0200
+++ b/loudmouth/lm-asyncns-resolver.c	Fri Aug 01 16:31:23 2008 +0200
@@ -337,5 +337,21 @@
 static void
 asyncns_resolver_cancel (LmResolver *resolver)
 {
+        LmAsyncnsResolverPriv *priv;
+
+        g_return_if_fail (LM_IS_ASYNCNS_RESOLVER (resolver));
+
+        priv = GET_PRIV (resolver);
+
+        if (priv->asyncns_ctx) {
+                if (priv->resolv_query) {
+                        asyncns_cancel (priv->asyncns_ctx, priv->resolv_query);
+                        priv->resolv_query = NULL;
+                }
+
+                _lm_resolver_set_result (resolver,
+                                         LM_RESOLVER_RESULT_CANCELLED,
+                                         NULL);
+        }
 }
 
--- a/loudmouth/lm-old-socket.c	Fri Aug 01 15:48:25 2008 +0200
+++ b/loudmouth/lm-old-socket.c	Fri Aug 01 16:31:23 2008 +0200
@@ -39,14 +39,15 @@
 #include <resolv.h>
 
 #include "lm-debug.h"
+#include "lm-error.h"
 #include "lm-internals.h"
 #include "lm-misc.h"
+#include "lm-proxy.h"
+#include "lm-resolver.h"
 #include "lm-ssl.h"
 #include "lm-ssl-internals.h"
-#include "lm-proxy.h"
+#include "lm-sock.h"
 #include "lm-old-socket.h"
-#include "lm-sock.h"
-#include "lm-error.h"
 
 #ifdef HAVE_ASYNCNS
 #include <asyncns.h>
@@ -93,6 +94,8 @@
 
 	guint          ref_count;
 
+        LmResolver      *resolver;
+
 #ifdef HAVE_ASYNCNS
 	GSource		*watch_resolv;
 	asyncns_query_t *resolv_query;
--- a/loudmouth/lm-resolver.h	Fri Aug 01 15:48:25 2008 +0200
+++ b/loudmouth/lm-resolver.h	Fri Aug 01 16:31:23 2008 +0200
@@ -54,7 +54,8 @@
 
 typedef enum {
         LM_RESOLVER_RESULT_OK,
-        LM_RESOLVER_RESULT_FAILED
+        LM_RESOLVER_RESULT_FAILED,
+        LM_RESOLVER_RESULT_CANCELLED
 } LmResolverResult;
 
 typedef void (*LmResolverCallback) (LmResolver       *resolver,