[exprimental patch] wakeup instead of polling for dns
Johannes Hofmann <[email protected]>
| Newsgroups | gmane.comp.web.dillo.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi, attached experimental patch replaces the polling for DNS answers with the wakeup mechanism fltk provides. What do you think? Cheers, Johannes _______________________________________________ Dillo-dev mailing list [email protected] http://lists.auriga.wearlab.de/cgi-bin/mailman/listinfo/dillo-dev
dns_wakeup.diff
(text/plain, 2.5 KB)
diff -r 35e4c15029a0 src/dillo.cc
--- a/src/dillo.cc Thu Feb 02 20:35:28 2012 +0100
+++ b/src/dillo.cc Mon Feb 06 21:43:11 2012 +0100
@@ -434,6 +434,7 @@
}
}
+ Fl::lock();
Fl::run();
/*
diff -r 35e4c15029a0 src/dns.c
--- a/src/dns.c Thu Feb 02 20:35:28 2012 +0100
+++ b/src/dns.c Mon Feb 06 21:43:11 2012 +0100
@@ -24,6 +24,7 @@
#endif
+#include <assert.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
@@ -325,6 +326,9 @@
dns_server[channel].addr_list = hosts;
dns_server[channel].ip_ready = TRUE;
+ a_Wakeup_add(Dns_timeout_client,
+ INT2VOIDP(dns_server[channel].channel));
+
return NULL; /* (avoids a compiler warning) */
}
@@ -345,10 +349,6 @@
dFree(dns_server[channel].hostname);
dns_server[channel].hostname = dStrdup(hostname);
- /* Let's set a timeout client to poll the server channel (5 times/sec) */
- a_Timeout_add(0.2,Dns_timeout_client,
- INT2VOIDP(dns_server[channel].channel));
-
#ifdef D_DNS_THREADED
/* set the thread attribute to the detached state */
if (!thrATTRInitialized) {
@@ -465,19 +465,13 @@
int channel = VOIDP2INT(data);
DnsServer *srv = &dns_server[channel];
- if (srv->ip_ready) {
- if (srv->addr_list != NULL) {
- /* DNS succeeded, let's cache it */
- Dns_cache_add(srv->hostname, srv->addr_list);
- }
- Dns_serve_channel(channel);
- Dns_assign_channels();
- a_Timeout_remove(); /* Done! */
-
- } else {
- /* IP not already resolved, keep on trying... */
- a_Timeout_repeat(0.2, Dns_timeout_client, data);
+ assert (srv->ip_ready);
+ if (srv->addr_list != NULL) {
+ /* DNS succeeded, let's cache it */
+ Dns_cache_add(srv->hostname, srv->addr_list);
}
+ Dns_serve_channel(channel);
+ Dns_assign_channels();
}
diff -r 35e4c15029a0 src/timeout.cc
--- a/src/timeout.cc Thu Feb 02 20:35:28 2012 +0100
+++ b/src/timeout.cc Mon Feb 06 21:43:11 2012 +0100
@@ -41,3 +41,7 @@
/* in FLTK, timeouts run one time by default */
}
+void a_Wakeup_add(TimeoutCb_t cb, void *cbdata)
+{
+ Fl::awake(cb, cbdata);
+}
diff -r 35e4c15029a0 src/timeout.hh
--- a/src/timeout.hh Thu Feb 02 20:35:28 2012 +0100
+++ b/src/timeout.hh Mon Feb 06 21:43:11 2012 +0100
@@ -10,6 +10,7 @@
void a_Timeout_add(float t, TimeoutCb_t cb, void *cbdata);
void a_Timeout_repeat(float t, TimeoutCb_t cb, void *cbdata);
void a_Timeout_remove();
+void a_Wakeup_add(TimeoutCb_t cb, void *cbdata);
#ifdef __cplusplus