Make any_loaded_file_changed() more reliable
authorFabian Keil <fk@fabiankeil.de>
Fri, 7 Dec 2012 12:43:05 +0000 (12:43 +0000)
committerFabian Keil <fk@fabiankeil.de>
Fri, 7 Dec 2012 12:43:05 +0000 (12:43 +0000)
Using the timestamps from csp->config->config_file_list
doesn't always work as they are only updated when the
config file is changed.

If an action or filter file is reloaded the timestamps
aren't updated so any_loaded_file_changed() continued
to report file changes.

jcc.c
loaders.c
loaders.h

diff --git a/jcc.c b/jcc.c
index 7d3b723..919e199 100644 (file)
--- a/jcc.c
+++ b/jcc.c
@@ -1,4 +1,4 @@
-const char jcc_rcs[] = "$Id: jcc.c,v 1.416 2012/11/24 14:01:25 fabiankeil Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 1.417 2012/11/24 14:04:29 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/jcc.c,v $
@@ -2666,7 +2666,7 @@ static void serve(struct client_state *csp)
          }
       }
 
-      if (continue_chatting && any_loaded_file_changed(csp->config->config_file_list))
+      if (continue_chatting && any_loaded_file_changed(csp))
       {
          continue_chatting = 0;
          config_file_change_detected = 1;
index 0e67da2..ae4f9c0 100644 (file)
--- a/loaders.c
+++ b/loaders.c
@@ -1,4 +1,4 @@
-const char loaders_rcs[] = "$Id: loaders.c,v 1.92 2012/07/23 12:43:56 fabiankeil Exp $";
+const char loaders_rcs[] = "$Id: loaders.c,v 1.93 2012/10/21 12:53:33 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/loaders.c,v $
@@ -1446,18 +1446,40 @@ static int file_has_been_modified(const char *filename, time_t last_know_modific
  *               FALSE otherwise.
  *
  *********************************************************************/
-int any_loaded_file_changed(const struct file_list *files_to_check)
+int any_loaded_file_changed(const struct client_state *csp)
 {
-   const struct file_list *file_to_check = files_to_check;
+   const struct file_list *file_to_check = csp->config->config_file_list;
+   int i;
+
+   if (file_has_been_modified(file_to_check->filename, file_to_check->lastmodified))
+   {
+      return TRUE;
+   }
+
+   for (i = 0; i < MAX_AF_FILES; i++)
+   {
+      if (csp->actions_list[i])
+      {
+         file_to_check = csp->actions_list[i];
+         if (file_has_been_modified(file_to_check->filename, file_to_check->lastmodified))
+         {
+            return TRUE;
+         }
+      }
+   }
 
-   while (file_to_check != NULL)
+   for (i = 0; i < MAX_AF_FILES; i++)
    {
-      if (file_has_been_modified(file_to_check->filename, file_to_check->lastmodified))
+      if (csp->rlist[i])
       {
-         return TRUE;
+         file_to_check = csp->rlist[i];
+         if (file_has_been_modified(file_to_check->filename, file_to_check->lastmodified))
+         {
+            return TRUE;
+         }
       }
-      file_to_check = file_to_check->next;
    }
+
    return FALSE;
 }
 
index c50a2d4..dd38514 100644 (file)
--- a/loaders.h
+++ b/loaders.h
@@ -1,6 +1,6 @@
 #ifndef LOADERS_H_INCLUDED
 #define LOADERS_H_INCLUDED
-#define LOADERS_H_VERSION "$Id: loaders.h,v 1.28 2011/04/19 13:00:47 fabiankeil Exp $"
+#define LOADERS_H_VERSION "$Id: loaders.h,v 1.29 2011/09/04 11:10:56 fabiankeil Exp $"
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/loaders.h,v $
@@ -102,7 +102,7 @@ extern void add_loader(int (*loader)(struct client_state *),
                        struct configuration_spec * config);
 extern int run_loader(struct client_state *csp);
 
-extern int any_loaded_file_changed(const struct file_list *files_to_check);
+extern int any_loaded_file_changed(const struct client_state *csp);
 
 /* Revision control strings from this header and associated .c file */
 extern const char loaders_rcs[];