From f403f37cbe9b9f6b213bb6ffefc083e1d33f0a96 Mon Sep 17 00:00:00 2001 From: Boian Bonev Date: Mon, 21 May 2012 20:56:44 +0300 Subject: [PATCH] never dequeue event for send_ping because it may remove it on error, use the ev_first instead; reset ev_next and ev_prev when a HOST_ENTRY is dequeued or removed because re-adding it relies these two to be NULL --- src/fping.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/fping.c b/src/fping.c index bc502d6..c08337f 100644 --- a/src/fping.c +++ b/src/fping.c @@ -1104,12 +1104,12 @@ void main_loop() lt = timeval_diff( ¤t_time, &last_send_time ); if(lt < interval) goto wait_for_reply; - /* Dequeue the event */ - h = ev_dequeue(); - /* Send the ping */ /*printf("Sending ping after %d ms\n", lt/100); */ - if(!send_ping(s, h)) goto wait_for_reply; + if(!send_ping(s, ev_first)) goto wait_for_reply; + + /* Dequeue the event */ + h = ev_dequeue(); /* Check what needs to be done next */ if(!loop_flag && !count_flag) { @@ -2768,6 +2768,7 @@ HOST_ENTRY *ev_dequeue() } dequeued = ev_first; ev_remove(dequeued); + dequeued->ev_next=dequeued->ev_prev=NULL; return dequeued; } @@ -2791,6 +2792,7 @@ void ev_remove(HOST_ENTRY *h) if(h->ev_next) { h->ev_next->ev_prev = h->ev_prev; } + h->ev_next=h->ev_prev=NULL; }