source: trunk/third/moira/dbck/phase3.pc @ 24319

Revision 24319, 2.2 KB checked in by broder, 14 years ago (diff)
New Moira snapshot from SVN.
RevLine 
[24319]1/* $Id: phase3.pc 3956 2010-01-05 20:56:56Z zacheiss $
[23095]2 *
3 * (c) Copyright 1988-1998 by the Massachusetts Institute of Technology.
4 * For copying and distribution information, please see the file
5 * <mit-copyright.h>.
6 */
7
8#include <mit-copyright.h>
9#include <moira.h>
10#include "dbck.h"
11
12#include <stdio.h>
13
[24319]14RCSID("$HeadURL: svn+ssh://svn.mit.edu/moira/trunk/moira/dbck/phase3.pc $ $Id: phase3.pc 3956 2010-01-05 20:56:56Z zacheiss $");
[23095]15
16void empty_list_check(int id, void *list, void *hint);
17void unref_string_check(int id, void *string, void *hint);
18void noclu_mach_check(int id, void *machine, void *hint);
19
20void empty_list_check(int id, void *list, void *hint)
21{
22  struct list *l = list;
23  if (l->members == 0 && l->list_id != 0)
24    printf("Warning: List %s is empty\n", l->name);
25}
26
27
28/* Used by other parts of the program to check that a string_id is good.
29 * This returns the stringif it is, or NULL if it is not, and as a side effect
30 * increments the string reference count.
31 */
32
33struct string *string_check(int id)
34{
35  struct string *s;
36
37  s = (struct string *) hash_lookup(strings, id);
38  if (!s)
39    return s;
40  s->refc++;
41  return s;
42}
43
44
45void unref_string_check(int id, void *string, void *hint)
46{
47  struct string *s = string;
48
49  if (s->refc == 0)
50    {
51      printf("Unreferenced string %s id %d\n", s->name, id);
52      if (single_fix("Delete", 1))
53        single_delete("strings", "string_id", id);
54    }
55}
56
57/*  This test was disabled because the MIT Moira server, which
58 *  initially only managed host information for workstations and
59 *  servers in the Athena Computing Environment, has been extended to
60 *  manage all hosts in the MIT.EDU domain (but not subdomains).
61 */
62void noclu_mach_check(int id, void *machine, void *hint)
63{
64  struct machine *m = machine;
65
66  if (m->clucount == 0 && m->mach_id != 0)
67    printf("Warning: machine %s is not in any clusters\n", m->name);
68}
69
70void phase3(void)
71{
72  printf("Phase 3 - Finding unused objects\n");
73
74  if (warn)
75    {
76#ifndef ATHENA
77      dprintf("Checking machines...\n");
78      hash_step(machines, noclu_mach_check, NULL);
79#endif
80      dprintf("Checking lists...\n");
81      hash_step(lists, empty_list_check, NULL);
82    }
83
84  dprintf("Checking strings...\n");
85  hash_step(strings, unref_string_check, NULL);
86}
87
Note: See TracBrowser for help on using the repository browser.