shithub: riscv

Download patch

ref: 486523bbc57b111d198432d2416e598c6d5c2d63
parent: bbce9c0566da28911f0ce444d0fdca0fe4eb77b9
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Mon Feb 6 06:19:45 EST 2017

ip/ipconfig: have to refresh /net/cs, /net/dns after ndbconfig even tho /net/ndb didnt got written

--- a/sys/src/cmd/ip/ipconfig/ipconfig.h
+++ b/sys/src/cmd/ip/ipconfig/ipconfig.h
@@ -132,6 +132,7 @@
 int	parseverb(char*);
 void	procsetname(char *fmt, ...);
 void	putndb(void);
+void	refresh(void);
 ulong	randint(ulong low, ulong hi);
 void	usage(void);
 int	validip(uchar*);
--- a/sys/src/cmd/ip/ipconfig/main.c
+++ b/sys/src/cmd/ip/ipconfig/main.c
@@ -648,8 +648,11 @@
 		dhcpwatch(0);
 
 	/* leave everything we've learned somewhere other procs can find it */
-	if(beprimary && !dondbconfig)
-		putndb();
+	if(beprimary){
+		if(!dondbconfig)
+			putndb();
+		refresh();
+	}
 }
 
 void
@@ -991,8 +994,10 @@
 			 * leave everything we've learned somewhere that
 			 * other procs can find it.
 			 */
-			if(beprimary)
+			if(beprimary){
 				putndb();
+				refresh();
+			}
 		}
 	}
 }
@@ -1641,6 +1646,24 @@
 	return p;
 }
 
+void
+refresh(void)
+{
+	char file[64];
+	int fd;
+
+	snprint(file, sizeof file, "%s/cs", conf.mpoint);
+	if((fd = open(file, OWRITE)) >= 0){
+		write(fd, "refresh", 7);
+		close(fd);
+	}
+	snprint(file, sizeof file, "%s/dns", conf.mpoint);
+	if((fd = open(file, OWRITE)) >= 0){
+		write(fd, "refresh", 7);
+		close(fd);
+	}
+}
+
 /* make an ndb entry and put it into /net/ndb for the servers to see */
 void
 putndb(void)
@@ -1699,17 +1722,6 @@
 		return;
 	write(fd, buf, p-buf);
 	close(fd);
-
-	snprint(file, sizeof file, "%s/cs", conf.mpoint);
-	if((fd = open(file, OWRITE)) >= 0){
-		write(fd, "refresh", 7);
-		close(fd);
-	}
-	snprint(file, sizeof file, "%s/dns", conf.mpoint);
-	if((fd = open(file, OWRITE)) >= 0){
-		write(fd, "refresh", 7);
-		close(fd);
-	}
 }
 
 /* return number of networks */