[PVFS2-CVS] commit by robl in pvfs2-1/src/io/job: job-desc-queue.c

CVS commit program cvs at parl.clemson.edu
Tue Jun 7 16:35:59 EDT 2005


Update of /projects/cvsroot/pvfs2-1/src/io/job
In directory parlweb:/tmp/cvs-serv3517/src/io/job

Modified Files:
	job-desc-queue.c 
Log Message:
one of phil's insure patches: "prevents job desc queue from counting on value
of previously free'd pointer when iterating queue at one point"


Index: job-desc-queue.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/io/job/job-desc-queue.c,v
diff -u -w -p -u -r1.14 -r1.15
--- job-desc-queue.c	1 Sep 2004 18:08:07 -0000	1.14
+++ job-desc-queue.c	7 Jun 2005 19:35:59 -0000	1.15
@@ -94,6 +94,8 @@ job_desc_q_p job_desc_q_new(void)
  */
 void job_desc_q_cleanup(job_desc_q_p jdqp)
 {
+    job_desc_q_p iterator = NULL;
+    job_desc_q_p scratch = NULL;
     struct job_desc *tmp_job_desc = NULL;
 
     if (s_job_desc_q_mutex)
@@ -101,15 +103,14 @@ void job_desc_q_cleanup(job_desc_q_p jdq
         gen_mutex_lock(s_job_desc_q_mutex);
         if (jdqp)
         {
-            do
+            qlist_for_each_safe(iterator, scratch, jdqp)
             {
-                tmp_job_desc = job_desc_q_shownext(jdqp);
-                if (tmp_job_desc)
-                {
-                    job_desc_q_remove(tmp_job_desc);
+                tmp_job_desc = qlist_entry(iterator, struct job_desc,
+                        job_desc_q_lin); 
+                /* qlist_for_each_safe lets us iterate and remove nodes.  no
+                 * need to adjust pointers as we are freeing everything */
                     free(tmp_job_desc);
                 }
-            } while (tmp_job_desc);
 
             free(jdqp);
             jdqp = NULL;



More information about the PVFS2-CVS mailing list