pend_list items should be ordered by ascending due time. When there is
an existing item on the list and a new item is earlier, the old code would
insert it after, rather than before the existing item.

I believe we could use list_add_tail instead of __list_add but __list_add
may actually be easier for someone reading to code to get what's going on.

Signed-off-by: Andy Grover <[email protected]>
---
 usr/actor.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/usr/actor.c b/usr/actor.c
index 37b5024..2e1f038 100644
--- a/usr/actor.c
+++ b/usr/actor.c
@@ -96,7 +96,8 @@ actor_insert_on_pend_list(actor_t *thread, uint32_t 
delay_secs)
                          (long long)next_thread->ttschedule);
 
                if (time_after(next_thread->ttschedule, thread->ttschedule)) {
-                       list_add(&thread->list, &next_thread->list);
+                       /* insert new thread before the next thread */
+                       __list_add(&thread->list, next_thread->list.prev, 
&next_thread->list);
                        goto inserted;
                }
        }
-- 
2.1.0

-- 
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/d/optout.

Reply via email to