1: /*
2: * Copyright (c) 1986 Regents of the University of California.
3: * All rights reserved.
4: *
5: * Redistribution and use in source and binary forms are permitted
6: * provided that this notice is preserved and that due credit is given
7: * to the University of California at Berkeley. The name of the University
8: * may not be used to endorse or promote products derived from this
9: * software without specific prior written permission. This software
10: * is provided ``as is'' without express or implied warranty.
11: */
12:
13: #ifndef lint
14: static char sccsid[] = "@(#)db_reload.c 4.15 (Berkeley) 2/28/88";
15: #endif /* not lint */
16:
17: #include <sys/types.h>
18: #include <sys/time.h>
19: #include <netinet/in.h>
20: #include <stdio.h>
21: #include <syslog.h>
22: #include <arpa/nameser.h>
23: #include "ns.h"
24: #include "db.h"
25:
26: extern time_t resettime;
27:
28: /*
29: * Flush and reload data base.
30: */
31:
32: db_reload()
33: {
34: extern char *bootfile;
35:
36: #ifdef DEBUG
37: if (debug >= 3)
38: fprintf(ddt,"reload()\n");
39: #endif
40: syslog(LOG_NOTICE, "reloading nameserver\n");
41:
42: qflush();
43: sqflush();
44: fwdtab_free();
45: if (hashtab != NULL)
46: db_free(hashtab);
47: hashtab = NULL;
48: if (fcachetab != NULL)
49: db_free(fcachetab);
50: fcachetab = NULL;
51: db_inv_free();
52: fwdtab_free();
53: ns_init(bootfile);
54: time(&resettime);
55: }
56:
57: db_free(htp)
58: struct hashbuf *htp;
59: {
60: register struct databuf *dp, *nextdp;
61: register struct namebuf *np, *nextnp;
62: struct namebuf **npp, **nppend;
63:
64: npp = htp->h_tab;
65: nppend = npp + htp->h_size;
66: while (npp < nppend) {
67: for (np = *npp++; np != NULL; np = nextnp) {
68: if (np->n_hash != NULL)
69: db_free(np->n_hash);
70: (void) free((char *)np->n_dname);
71: for (dp = np->n_data; dp != NULL; ) {
72: nextdp = dp->d_next;
73: (void) free((char *)dp);
74: dp = nextdp;
75: }
76: nextnp = np->n_next;
77: free((char *)np);
78: }
79: }
80: (void) free((char *)htp);
81: }
82:
83: db_inv_free()
84: {
85: register struct invbuf *ip;
86: register int i, j;
87:
88: for (i = 0; i < INVHASHSZ; i++)
89: for (ip = invtab[i]; ip != NULL; ip = ip->i_next)
90: for (j = 0; j < INVBLKSZ; j++)
91: ip->i_dname[j] = NULL;
92: }
93:
94: fwdtab_free()
95: {
96: extern struct fwdinfo *fwdtab;
97: struct fwdinfo *fp, *nextfp;
98:
99: for (fp = fwdtab; fp != NULL; fp = nextfp) {
100: nextfp = fp->next;
101: free((char *)fp);
102: }
103: fwdtab = NULL;
104: }
Defined functions
Defined variables