Renamed the test to test-dns and fixed a bug in the asyncns resolver.
test-dns.c now just tests whatever dns LmResolver::new* gives.
Also checked that new_for_host works now with the asyncns resolver.
--- a/loudmouth/Makefile.am Thu Jul 31 19:50:01 2008 +0200
+++ b/loudmouth/Makefile.am Thu Jul 31 20:03:42 2008 +0200
@@ -13,11 +13,11 @@
-DRUNTIME_ENDIAN \
$(NULL)
-noinst_PROGRAMS = test-dns-blocking
+noinst_PROGRAMS = test-dns
-test_dns_blocking_SOURCES = test-dns-blocking.c
+test_dns_SOURCES = test-dns.c
-test_dns_blocking_LDADD = $(LOUDMOUTH_LIBS) $(top_builddir)/loudmouth/libloudmouth-1.la
+test_dns_LDADD = $(LOUDMOUTH_LIBS) $(top_builddir)/loudmouth/libloudmouth-1.la
lib_LTLIBRARIES = libloudmouth-1.la
--- a/loudmouth/lm-asyncns-resolver.c Thu Jul 31 19:50:01 2008 +0200
+++ b/loudmouth/lm-asyncns-resolver.c Thu Jul 31 20:03:42 2008 +0200
@@ -167,7 +167,7 @@
priv->resolv_channel,
G_IO_IN,
(GIOFunc) asyncns_resolver_done,
- socket);
+ resolver);
return TRUE;
}
--- a/loudmouth/lm-resolver.c Thu Jul 31 19:50:01 2008 +0200
+++ b/loudmouth/lm-resolver.c Thu Jul 31 20:03:42 2008 +0200
@@ -20,6 +20,7 @@
#include <config.h>
+#include "lm-asyncns-resolver.h"
#include "lm-blocking-resolver.h"
#include "lm-internals.h"
#include "lm-marshal.h"
@@ -267,7 +268,7 @@
g_return_val_if_fail (host != NULL, NULL);
g_return_val_if_fail (callback != NULL, NULL);
- resolver = g_object_new (LM_TYPE_BLOCKING_RESOLVER,
+ resolver = g_object_new (LM_TYPE_ASYNCNS_RESOLVER,
"type", LM_RESOLVER_HOST,
"host", host,
NULL);
--- a/loudmouth/test-dns-blocking.c Thu Jul 31 19:50:01 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-#include <loudmouth.h>
-#include "lm-blocking-resolver.h"
-
-GMainLoop *main_loop;
-
-static void
-resolver_result_cb (LmResolver *resolver,
- LmResolverResult result,
- gpointer user_data)
-{
- gchar *host;
- struct addrinfo *addr;
-
- g_object_get (resolver, "host", &host, NULL);
-
- if (result != LM_RESOLVER_RESULT_OK) {
- g_print ("Failed to lookup %s\n", host);
- g_free (host);
- return;
- }
-
- g_print ("In %s\n", G_STRFUNC);
-
- while ((addr = lm_resolver_results_get_next (resolver))) {
- g_print ("Result!\n");
- }
-
- g_free (host);
-
- g_main_loop_quit (main_loop);
-}
-
-int
-main (int argc, char **argv)
-{
- LmResolver *resolver;
- LmResolver *srv_resolver;
-
- g_type_init ();
-
- resolver = lm_resolver_new_for_host ("kenny.imendio.com",
- resolver_result_cb,
- NULL);
- lm_resolver_lookup (resolver);
-
- srv_resolver = lm_resolver_new_for_service ("jabber.org",
- "xmpp-client", "tcp",
- resolver_result_cb,
- NULL);
- lm_resolver_lookup (srv_resolver);
-
- g_print ("Running main loop\n");
-
- main_loop = g_main_loop_new (NULL, FALSE);
- g_main_loop_run (main_loop);
-
- g_print ("Finished\n");
-
- return 0;
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/test-dns.c Thu Jul 31 20:03:42 2008 +0200
@@ -0,0 +1,64 @@
+#include <loudmouth.h>
+#include "lm-blocking-resolver.h"
+
+GMainLoop *main_loop;
+
+static void
+resolver_result_cb (LmResolver *resolver,
+ LmResolverResult result,
+ gpointer user_data)
+{
+ gchar *host;
+ struct addrinfo *addr;
+
+ g_object_get (resolver, "host", &host, NULL);
+
+ if (result != LM_RESOLVER_RESULT_OK) {
+ g_print ("Failed to lookup %s\n", host);
+ g_free (host);
+ return;
+ }
+
+ g_print ("In %s\n", G_STRFUNC);
+
+ while ((addr = lm_resolver_results_get_next (resolver))) {
+ g_print ("Result!\n");
+ }
+
+ g_free (host);
+
+ g_main_loop_quit (main_loop);
+}
+
+int
+main (int argc, char **argv)
+{
+ LmResolver *resolver;
+ /*
+ LmResolver *srv_resolver;
+ */
+
+ g_type_init ();
+
+ resolver = lm_resolver_new_for_host ("kenny.imendio.com",
+ resolver_result_cb,
+ NULL);
+ lm_resolver_lookup (resolver);
+
+ /*
+ srv_resolver = lm_resolver_new_for_service ("jabber.org",
+ "xmpp-client", "tcp",
+ resolver_result_cb,
+ NULL);
+ lm_resolver_lookup (srv_resolver);
+ */
+
+ g_print ("Running main loop\n");
+
+ main_loop = g_main_loop_new (NULL, FALSE);
+ g_main_loop_run (main_loop);
+
+ g_print ("Finished\n");
+
+ return 0;
+}