[Date Prev]   [Date Next] [Thread Prev]   [Thread Next] [Date Index]   [Thread Index]

 

     [nocol-users] Sighup Handler for Portmon

This is for 4.2.1. Let me know how it works for you if you do use it.

--Nathan


____________________________________________________________________
Nathan Clemons, Systems Engineer
WinStar Internet and Hosting Services

800 South Main St. Mansfield, MA  02048
____________________________________________________________________  
nclemons@winstar.com    www.winstar.com    (v) 800-234-0002 ext.1109
nathan@ici.net                             (f) 508-261-0430

*** nocol-4.2.1/portmon/portmon.c	Wed Jan 12 11:11:28 2000
--- tmp/portmon.c	Thu Aug 13 07:32:45 1998
***************
*** 22,31 ****
  
  /*
   * $Log: portmon.c,v $
-  *
-  * Revision 1.9  2000/01/11 12:00:00  nathan
-  * Added signal handling to reread config files on a HUP signal
-  *
   * Revision 1.8  1998/08/13 11:31:48  vikas
   * Changed goto into a while() loop. Was core dumping on Solaris with
   * gcc v2.8.1. Patch sent in by durrell@innocence.com.
--- 22,27 ----
***************
*** 75,82 ****
  
  extern char	*skip_spaces() ;		/* in libnocol */
  
- void    sighuphandler();		/* for SIGHUP config rereading */
- 
  main(ac, av)
    int ac;
    char **av;
--- 71,76 ----
***************
*** 127,135 ****
    if (readconfig(fdout) == -1)
      nocol_done();
  
-   /* Set up the signal handler */
-   (void) signal(SIGHUP, sighuphandler);
- 
    lseek(fdout, (off_t)0, SEEK_SET);	/* rewind file */
    while (1)	/* forever */
    {
--- 121,126 ----
***************
*** 714,756 ****
  
  }
  
- /*
-  * reread config files when you get this...
-  */
- void sighuphandler () {
-    struct _harray tmp[MAXHOSTS];
-    int count_new, count_old;
-    int found, match;
- 
-    bzero ((char *)tmp, sizeof(tmp));
-    for (count_new = 0; hostarray[count_new].hname; ++count_new) {
-        /* have to be careful of NULL values, particularly on the send...
-           --nathan */
-        tmp[count_new].hname       = strdup(hostarray[count_new].hname);
-        tmp[count_new].ipaddr      = strdup(hostarray[count_new].ipaddr);
-        tmp[count_new].port        = hostarray[count_new].port;
-        tmp[count_new].maxseverity = hostarray[count_new].maxseverity;
-        tmp[count_new].timeouts[0] = hostarray[count_new].timeouts[0];
-        tmp[count_new].timeouts[1] = hostarray[count_new].timeouts[1];
-        tmp[count_new].timeouts[2] = hostarray[count_new].timeouts[2];
-    }
- 
-    fprintf(stderr, "Rereading the config file...");
-    readconfig(fdout);
-    for (count_new = 0; hostarray[count_new].hname; ++count_new) {
-        found = 0;
-        for (count_old = 0; (tmp[count_old].hname && !found); ++count_old) {
-            if (hostarray[count_new].hname &&
-                !strcmp(hostarray[count_new].hname, tmp[count_old].hname) &&
-                !strcmp(hostarray[count_new].ipaddr, tmp[count_old].ipaddr) &&
-                (hostarray[count_new].port == tmp[count_old].port)) {
-               hostarray[count_new].maxseverity = tmp[count_old].maxseverity;
-               hostarray[count_new].timeouts[0] = tmp[count_old].timeouts[0];
-               hostarray[count_new].timeouts[1] = tmp[count_old].timeouts[1];
-               hostarray[count_new].timeouts[2] = tmp[count_old].timeouts[2];
-               found = 1;
-            }
-        }
-    } 
-    fprintf(stderr, " done saving state information.\n");
- }
--- 705,707 ----