Author: titmuss
Date: Fri Feb 22 15:52:09 2008
New Revision: 2009
URL: http://svn.slimdevices.com?rev=2009&root=Jive&view=rev
Log:
[EMAIL PROTECTED] (orig r2006): titmuss | 2008-02-22 23:51:03 +0000
Bug: 7251
Description:
Clear the dns error when the resolv.conf file changes. This enables a
connection to
SqueezeNetwork following a factory reset.
Modified:
trunk/ (props changed)
trunk/jive/src/pkg/jive/src/net/jive_dns.c
Propchange: trunk/
------------------------------------------------------------------------------
--- svk:merge (original)
+++ svk:merge Fri Feb 22 15:52:09 2008
@@ -1,3 +1,3 @@
-bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/branches/7.0:2005
+bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/branches/7.0:2006
bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/branches/SN:1083
bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/branches/scrolling:1378
Modified: trunk/jive/src/pkg/jive/src/net/jive_dns.c
URL:
http://svn.slimdevices.com/trunk/jive/src/pkg/jive/src/net/jive_dns.c?rev=2009&root=Jive&r1=2008&r2=2009&view=diff
==============================================================================
--- trunk/jive/src/pkg/jive/src/net/jive_dns.c (original)
+++ trunk/jive/src/pkg/jive/src/net/jive_dns.c Fri Feb 22 15:52:09 2008
@@ -7,8 +7,10 @@
#include "common.h"
#ifdef _WIN32
-#include <winsock2.h>
+#include <winsock2.h>
#include <ws2tcpip.h>
+#else
+#include <sys/stat.h>
#endif
#define RESOLV_TIMEOUT (2 * 60 * 1000) /* 2 minutes */
@@ -73,6 +75,24 @@
}
+static int stat_resolv_conf(void) {
+#ifndef _WIN32
+ struct stat stat_buf;
+ static time_t last_mtime = 0;
+
+ /* check if resolv.conf has changed */
+ if (stat("/etc/resolv.conf", &stat_buf) == 0) {
+ if (last_mtime != stat_buf.st_mtime) {
+ last_mtime = stat_buf.st_mtime;
+ return 1;
+ }
+ }
+#endif
+
+ return 0;
+}
+
+
/* dns resolver thread */
static int dns_resolver_thread(void *p) {
int fd = (int) p;
@@ -89,7 +109,7 @@
/* broken pipe */
return 0;
}
-
+
buf = malloc(len + 1);
if (read(fd, buf, len) < 0) {
/* broken pipe */
@@ -98,16 +118,16 @@
}
buf[len] = '\0';
- if (failed_error) {
+
+ if (failed_error && !stat_resolv_conf()) {
Uint32 now = SDL_GetTicks();
if (now - failed_timeout < RESOLV_TIMEOUT) {
write_str(fd, failed_error);
continue;
}
-
- failed_error = NULL;
- }
+ }
+ failed_error = NULL;
if (inet_aton(buf, &byaddr)) {
hostent = gethostbyaddr((char *) &byaddr, sizeof(addr),
AF_INET);
_______________________________________________
Jive-checkins mailing list
[email protected]
http://lists.slimdevices.com/cgi-bin/mailman/listinfo/jive-checkins