/[radius]/radius/radiusd/radiusd.c
ViewVC logotype

Diff of /radius/radiusd/radiusd.c

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

revision 1.129 by gray, Sat Jun 7 11:00:48 2003 UTC revision 1.130 by gray, Wed Jun 11 20:47:51 2003 UTC
# Line 120  int acct_comp_flag; /* ... accounting re Line 120  int acct_comp_flag; /* ... accounting re
120  int checkrad_assume_logged = 1;  int checkrad_assume_logged = 1;
121  size_t max_requests = MAX_REQUESTS;  size_t max_requests = MAX_REQUESTS;
122  size_t max_children = MAX_CHILDREN;  size_t max_children = MAX_CHILDREN;
123    unsigned process_timeout = PROCESS_TIMEOUT;
124  char *exec_user = NULL;  char *exec_user = NULL;
125    
126  UINT4 warning_seconds;  UINT4 warning_seconds;
# Line 291  get_port_number(char *name, char *proto, Line 292  get_port_number(char *name, char *proto,
292  }  }
293    
294  static void  static void
295  radiusd_preconfig_hook(void *a ARG_UNUSED, void *b ARG_UNUSED)  terminate_subprocesses()
296  {  {
297          /* Flush any pending requests and empty the request queue */          int sig;
298    
299            /* Flush any pending requests and empty the request queue */
300          radiusd_flush_queue();          radiusd_flush_queue();
301          request_init_queue();          request_init_queue();
302                    
303          /* Terminate all subprocesses */          /* Terminate all subprocesses */
304          rpp_kill(-1, SIGTERM);          radlog(L_INFO, _("Terminating the subprocesses"));
305          sleep(2);          sig = SIGTERM;
306          radiusd_cleanup();          while (rpp_count()) {
307          if (rpp_count()) {                  rpp_kill(-1, sig);
308                  rpp_kill(-1, SIGKILL);                  sleep(2);
309                  radiusd_cleanup();                  radiusd_cleanup();
310                    sig = SIGKILL;
311          }          }
312    }
313    
314    static void
315    radiusd_preconfig_hook(void *a ARG_UNUSED, void *b ARG_UNUSED)
316    {
317            terminate_subprocesses();
318          input_close_channels(radius_input);          input_close_channels(radius_input);
319  }  }
320    
321  static void  static void
322  radiusd_postconfig_hook(void *a ARG_UNUSED, void *b ARG_UNUSED)  radiusd_postconfig_hook(void *a ARG_UNUSED, void *b ARG_UNUSED)
323  {  {
324          if (radius_count_channels() == 0) {          if (radius_mode = MODE_DAEMON && radius_count_channels() == 0) {
325                  radlog(L_ALERT,                  radlog(L_ALERT,
326                         _("Radiusd is not listening on any port. Trying to continue anyway..."));                         _("Radiusd is not listening on any port. Trying to continue anyway..."));
327          }          }
# Line 551  void Line 561  void
561  radiusd_suspend()  radiusd_suspend()
562  {  {
563          if (suspend_flag == 0) {          if (suspend_flag == 0) {
564                    terminate_subprocesses();
565                  radlog(L_NOTICE, _("RADIUSD SUSPENDED"));                  radlog(L_NOTICE, _("RADIUSD SUSPENDED"));
566                  suspend_flag = 1;                  suspend_flag = 1;
567          }          }
# Line 560  void Line 571  void
571  radiusd_continue()  radiusd_continue()
572  {  {
573          if (suspend_flag) {          if (suspend_flag) {
574                    terminate_subprocesses();
575                  suspend_flag = 0;                  suspend_flag = 0;
576  #ifdef USE_SNMP  #ifdef USE_SNMP
577                  server_stat->auth.status = serv_running;                  server_stat->auth.status = serv_running;
# Line 657  radiusd_restart() Line 669  radiusd_restart()
669                  return;                  return;
670          }          }
671    
672          radiusd_flush_queue();          radiusd_run_preconfig_hooks(NULL);
673    
674          if (foreground)          if (foreground)
675                  pid = 0; /* make-believe we're child */                  pid = 0; /* make-believe we're child */
# Line 669  radiusd_restart() Line 681  radiusd_restart()
681                  return;                  return;
682          }          }
683                    
         input_close_channels(radius_input);  
684          radiusd_signal_init(SIG_DFL);          radiusd_signal_init(SIG_DFL);
685          if (pid > 0) {          if (pid > 0) {
686                  /* Parent */                  /* Parent */
# Line 688  radiusd_restart() Line 699  radiusd_restart()
699          /*NOTREACHED*/          /*NOTREACHED*/
700  }  }
701    
702    
703    
704    static int
705    radiusd_rpp_wait(void *arg)
706    {
707            time_t *tp = arg;
708            struct timeval tv;
709    
710            if (time(NULL) > *tp)
711                    return 1;
712            
713            tv.tv_sec = 2;
714            tv.tv_usec = 0;
715            input_select_channel(radius_input, "rpp", &tv);
716            return 0;
717    }
718    
719  void  void
720  radiusd_flush_queue()  radiusd_flush_queue()
721  {  {
722          rpp_flush();          time_t t;
723            unsigned i, delta = 0;
724    
725            for (i = 0; i < R_MAX; i++)
726                    if (delta < request_class[i].ttl)
727                            delta = request_class[i].ttl;
728    
729            time(&t);
730            t += delta;
731            rpp_flush(radiusd_rpp_wait, &t);
732  }  }
733                                    
734  void  void
# Line 1237  struct cfg_stmt option_stmt[] = { Line 1274  struct cfg_stmt option_stmt[] = {
1274            NULL, NULL },            NULL, NULL },
1275          { "max-processes", CS_STMT, NULL, cfg_get_integer, &max_children,          { "max-processes", CS_STMT, NULL, cfg_get_integer, &max_children,
1276            NULL, NULL },            NULL, NULL },
1277            { "process-idle-timeout", CS_STMT, NULL, cfg_get_integer, &process_timeout,
1278              NULL, NULL },
1279          { "exec-program-user", CS_STMT, NULL, cfg_get_string, &exec_user,          { "exec-program-user", CS_STMT, NULL, cfg_get_string, &exec_user,
1280            NULL, NULL },            NULL, NULL },
1281          { "log-dir", CS_STMT, NULL, cfg_get_string, &radlog_dir,          { "log-dir", CS_STMT, NULL, cfg_get_string, &radlog_dir,

Legend:
Removed from v.1.129  
changed lines
  Added in v.1.130

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