/[monit]/monit/p.y
ViewVC logotype

Diff of /monit/p.y

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.46 by hauk, Tue Dec 17 19:55:17 2002 UTC revision 1.47 by hauk, Thu Dec 19 20:50:06 2002 UTC
# Line 168  Line 168 
168    static void createprocinfo();    static void createprocinfo();
169    static char *append_hostname(char *);    static char *append_hostname(char *);
170    static void cleanup_md5_string(char *);    static void cleanup_md5_string(char *);
171      static void check_depend();
172      static void search_depend(Process_T p);
173  %}  %}
174    
175  %union {  %union {
# Line 663  int parse(char *controlfile) { Line 665  int parse(char *controlfile) {
665    
666    }    }
667    
668      /* Post-parse check the sanity of any dependency graph */
669      check_depend();
670        
671    return ( cfg_errflag == 0 );    return ( cfg_errflag == 0 );
672        
673  }  }
# Line 755  static void addprocess(Process_T p) { Line 760  static void addprocess(Process_T p) {
760    
761  }  }
762    
763    
764  /*  /*
765   * Add a dependant entry to the current process dependant list   * Add a dependant entry to the current process dependant list
766   *   *
# Line 774  static void adddependant(char *dependant Line 780  static void adddependant(char *dependant
780    
781  }  }
782    
783    
784  /*  /*
785   * Add a filename and its associated md5 checksum   * Add a filename and its associated md5 checksum
786   * to the current process checksumlist   * to the current process checksumlist
# Line 1315  static void check_hostname(char *hostnam Line 1322  static void check_hostname(char *hostnam
1322  }  }
1323    
1324    
1325    /*
1326     * Check the dependency graph for any errors
1327     */
1328    static void check_depend() {
1329    
1330      Process_T p;
1331      
1332      for (p= processlist; p; p= p->next) {
1333        if(p->visited)
1334            continue;
1335        search_depend(p);
1336      }
1337      
1338      reset_depend();
1339      
1340    }
1341    
1342    
1343    
1344  /* -------------------------------------------------------------------- Misc */  /* -------------------------------------------------------------------- Misc */
1345    
1346    
# Line 1340  static char *append_hostname(char *addr) Line 1366  static char *append_hostname(char *addr)
1366    
1367  }  }
1368    
1369    
1370  /*  /*
1371   * Cleans up an md5 string, tolower and remove byte sperators   * Cleans up an md5 string, tolower and remove byte sperators
1372   */   */
   
1373  static void cleanup_md5_string(char *md5string) {  static void cleanup_md5_string(char *md5string) {
1374    
1375    int i= 0, j= 0;    int i= 0, j= 0;
# Line 1368  static void cleanup_md5_string(char *md5 Line 1394  static void cleanup_md5_string(char *md5
1394    return;    return;
1395    
1396  }  }
1397    
1398    
1399    /*
1400     * Search for any errors in the process dependency graph
1401     */
1402    static void search_depend(Process_T p) {
1403    
1404      if(p->visited)
1405          return;
1406      
1407      if(p->dependantlist) {
1408        
1409        Dependant_T d;
1410        
1411        for(d= p->dependantlist; d; d= d->next ) {
1412          
1413          Process_T dp= get_process(d->dependant);
1414          
1415          if(!dp) {
1416            log("%s: Error, depend process '%s' is not defined in the "
1417                "control file\n", prog, d->dependant);
1418            exit(1);
1419          }
1420          
1421          if(dp->depend_visited) {
1422            log("%s: Error, found a depend loop in the control file involving "
1423                "the process '%s'\n", prog, p->name);
1424            exit(1);
1425          }
1426          
1427          dp->depend_visited= TRUE;
1428          search_depend(dp);
1429          
1430        }
1431      }
1432      
1433      p->visited= TRUE;
1434    
1435    }

Legend:
Removed from v.1.46  
changed lines
  Added in v.1.47

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26