clean hostlist when going from master to slave (from ks@purdue)
authorJim Bloom <bloom@ucbvax.Berkeley.EDU>
Tue, 18 Feb 1986 05:18:18 +0000 (21:18 -0800)
committerJim Bloom <bloom@ucbvax.Berkeley.EDU>
Tue, 18 Feb 1986 05:18:18 +0000 (21:18 -0800)
SCCS-vsn: usr.sbin/timed/timed/timed.c 2.3
SCCS-vsn: usr.sbin/timed/timed/master.c 2.2

usr/src/usr.sbin/timed/timed/master.c
usr/src/usr.sbin/timed/timed/timed.c

index 99a85a1..13ec7f7 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)master.c   2.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)master.c   2.2 (Berkeley) %G%";
 #endif not lint
 
 #include "globals.h"
 #endif not lint
 
 #include "globals.h"
@@ -422,6 +422,39 @@ struct sockaddr_in *addr;
        return(ret);
 }
 
        return(ret);
 }
 
+/*
+ * Remove all the machines from the host table that exist on the given
+ * network.  This is called when a master transitions to a slave on a
+ * given network.
+ */
+
+rmnetmachs(ntp)
+       register struct netinfo *ntp;
+{
+       int i;
+
+       if (trace)
+               prthp();
+       for (i = 1; i < slvcount; i++)
+               if ((hp[i].addr.sin_addr.s_addr & ntp->mask) == ntp->net)
+                       rmmach(i--);
+       if (trace)
+               prthp();
+}
+
+/*
+ * remove the machine with the given index in the host table.
+ */
+rmmach(ind)
+       int ind;
+{
+       if (trace)
+               fprintf(fd, "rmmach: %s\n", hp[ind].name);
+       if (slvcount-ind-1 > 0)
+               bcopy(&hp[ind+1], &hp[ind], (slvcount-ind-1)*sizeof(hp[ind]));
+       slvcount--;
+}
+
 prthp()
 {
        int i;
 prthp()
 {
        int i;
index 11dc96c..39b0181 100644 (file)
@@ -11,7 +11,7 @@ char copyright[] =
 #endif not lint
 
 #ifndef lint
 #endif not lint
 
 #ifndef lint
-static char sccsid[] = "@(#)timed.c    2.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)timed.c    2.3 (Berkeley) %G%";
 #endif not lint
 
 #include "globals.h"
 #endif not lint
 
 #include "globals.h"
@@ -422,6 +422,7 @@ char **argv;
                                if ((from.sin_addr.s_addr & ntp->mask) ==
                                    ntp->net) {
                                        ntp->status = SLAVE;
                                if ((from.sin_addr.s_addr & ntp->mask) ==
                                    ntp->net) {
                                        ntp->status = SLAVE;
+                                       rmnetmachs(ntp);
                                        break;
                                }
                        }
                                        break;
                                }
                        }