Annotation of 43BSDTahoe/etc/named/db_reload.c, revision 1.1.1.1

1.1       root        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 the above copyright notice and this paragraph are
                      7:  * duplicated in all such forms and that any documentation,
                      8:  * advertising materials, and other materials related to such
                      9:  * distribution and use acknowledge that the software was developed
                     10:  * by the University of California, Berkeley.  The name of the
                     11:  * University may not be used to endorse or promote products derived
                     12:  * from this software without specific prior written permission.
                     13:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
                     14:  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
                     15:  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                     16:  */
                     17: 
                     18: #ifndef lint
                     19: static char sccsid[] = "@(#)db_reload.c        4.16 (Berkeley) 6/18/88";
                     20: #endif /* not lint */
                     21: 
                     22: #include <sys/types.h>
                     23: #include <sys/time.h>
                     24: #include <netinet/in.h>
                     25: #include <stdio.h>
                     26: #include <syslog.h>
                     27: #include <arpa/nameser.h>
                     28: #include "ns.h"
                     29: #include "db.h"
                     30: 
                     31: extern time_t  resettime;
                     32: 
                     33: /*
                     34:  * Flush and reload data base.
                     35:  */
                     36: 
                     37: db_reload()
                     38: {
                     39:        extern char *bootfile;
                     40: 
                     41: #ifdef DEBUG
                     42:        if (debug >= 3)
                     43:                fprintf(ddt,"reload()\n");
                     44: #endif
                     45:        syslog(LOG_NOTICE, "reloading nameserver\n");
                     46: 
                     47:        qflush();
                     48:        sqflush();
                     49:        fwdtab_free();
                     50:        if (hashtab != NULL)
                     51:                db_free(hashtab);
                     52:        hashtab = NULL;
                     53:        if (fcachetab != NULL)
                     54:                db_free(fcachetab);
                     55:        fcachetab = NULL;
                     56:        db_inv_free();
                     57:        fwdtab_free();
                     58:        ns_init(bootfile);
                     59:        time(&resettime);
                     60: }
                     61: 
                     62: db_free(htp)
                     63:        struct hashbuf *htp;
                     64: {
                     65:        register struct databuf *dp, *nextdp;
                     66:        register struct namebuf *np, *nextnp;
                     67:        struct namebuf **npp, **nppend;
                     68: 
                     69:        npp = htp->h_tab;
                     70:        nppend = npp + htp->h_size;
                     71:        while (npp < nppend) {
                     72:            for (np = *npp++; np != NULL; np = nextnp) {
                     73:                if (np->n_hash != NULL)
                     74:                        db_free(np->n_hash);
                     75:                (void) free((char *)np->n_dname);
                     76:                for (dp = np->n_data; dp != NULL; ) {
                     77:                        nextdp = dp->d_next;
                     78:                        (void) free((char *)dp);
                     79:                        dp = nextdp;
                     80:                }
                     81:                nextnp = np->n_next;
                     82:                free((char *)np);
                     83:            }
                     84:        }
                     85:        (void) free((char *)htp);
                     86: }
                     87: 
                     88: db_inv_free()
                     89: {
                     90:        register struct invbuf *ip;
                     91:        register int i, j;
                     92: 
                     93:        for (i = 0; i < INVHASHSZ; i++)
                     94:                for (ip = invtab[i]; ip != NULL; ip = ip->i_next)
                     95:                        for (j = 0; j < INVBLKSZ; j++)
                     96:                                ip->i_dname[j] = NULL;
                     97: }
                     98: 
                     99: fwdtab_free()
                    100: {
                    101:        extern  struct fwdinfo *fwdtab;
                    102:        struct fwdinfo *fp, *nextfp;
                    103: 
                    104:        for (fp = fwdtab; fp != NULL; fp = nextfp) {
                    105:                nextfp = fp->next;
                    106:                free((char *)fp);
                    107:        }
                    108:        fwdtab = NULL;
                    109: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.