Author: titmuss
Date: Fri Feb 22 15:51:03 2008
New Revision: 2006

URL: http://svn.slimdevices.com?rev=2006&root=Jive&view=rev
Log:
Bug: 7251
Description:
Clear the dns error when the resolv.conf file changes. This enables a 
connection to 
SqueezeNetwork following a factory reset.


Modified:
    branches/7.0/jive/src/pkg/jive/src/net/jive_dns.c

Modified: branches/7.0/jive/src/pkg/jive/src/net/jive_dns.c
URL: 
http://svn.slimdevices.com/branches/7.0/jive/src/pkg/jive/src/net/jive_dns.c?rev=2006&root=Jive&r1=2005&r2=2006&view=diff
==============================================================================
--- branches/7.0/jive/src/pkg/jive/src/net/jive_dns.c (original)
+++ branches/7.0/jive/src/pkg/jive/src/net/jive_dns.c Fri Feb 22 15:51:03 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

Reply via email to