sweep: Made loop structure of sweep step mirror that of mark step
[privoxy.git] / loaders.c
index 3221812..35a910e 100644 (file)
--- a/loaders.c
+++ b/loaders.c
@@ -1,4 +1,4 @@
-const char loaders_rcs[] = "$Id: loaders.c,v 1.50.2.1 2002/07/26 15:19:24 oes Exp $";
+const char loaders_rcs[] = "$Id: loaders.c,v 1.50.2.4 2003/05/06 15:57:12 oes Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/Attic/loaders.c,v $
@@ -35,6 +35,18 @@ const char loaders_rcs[] = "$Id: loaders.c,v 1.50.2.1 2002/07/26 15:19:24 oes Ex
  *
  * Revisions   :
  *    $Log: loaders.c,v $
+ *    Revision 1.50.2.4  2003/05/06 15:57:12  oes
+ *    Bugfix: Update last_active pointer in sweep() before
+ *    leaving an active client. Closes bugs #724395, #727882
+ *
+ *    Revision 1.50.2.3  2002/11/20 17:12:30  oes
+ *    Ooops, forgot one change.
+ *
+ *    Revision 1.50.2.2  2002/11/20 14:38:15  oes
+ *    Fixed delayed/incomplete freeing of client resources and
+ *    simplified loop structure in sweep.
+ *    Thanks to Oliver Stoeneberg for the hint.
+ *
  *    Revision 1.50.2.1  2002/07/26 15:19:24  oes
  *    - PCRS jobs now chained in order of appearance. Previous
  *      reverse chaining was counter-intuitive.
@@ -395,6 +407,9 @@ void sweep(void)
             csp->tlist->active = 1;
          }
 #endif /* def FEATURE_TRUST */
+         
+         last_active = csp;
+         csp = csp->next;
 
       }
       else 
@@ -431,17 +446,26 @@ void sweep(void)
       }
    }
 
-   for (fl = files; fl && ((nfl = fl->next) != NULL) ; fl = fl->next)
+   nfl = files;
+   fl = files->next;
+
+   while (fl != NULL)
    {
-      if ( ( 0 == nfl->active ) && ( NULL != nfl->unloader ) )
+      if ( ( 0 == fl->active ) && ( NULL != fl->unloader ) )
       {
-         fl->next = nfl->next;
+         nfl->next = fl->next;
 
-         (nfl->unloader)(nfl->f);
+         (fl->unloader)(fl->f);
 
-         freez(nfl->filename);
+         freez(fl->filename);
+         freez(fl);
 
-         freez(nfl);
+         fl = nfl->next;
+      }
+      else
+      {
+         nfl = fl;
+         fl = fl->next;
       }
    }
 
@@ -503,6 +527,7 @@ int check_file_changed(const struct file_list * current,
       return 1;
    }
 
+
    fs->filename = strdup(filename);
    fs->lastmodified = statbuf->st_mtime;