Re: lftp 3.5.2 bug
"Alexander V. Lukyanov" <[email protected]> Fri, 4 Aug 2006 11:02:48 +0400
| Newsgroups | gmane.network.lftp.devel |
|---|---|
| Message-ID | <[email protected]> |
On Thu, Aug 03, 2006 at 04:08:44PM -0400, Ian Gulliver wrote: > 3.5.2 official source segfaults (sometimes) after switching queue items > during upload. When compiled with --with-debug and run under gdb, it > outputs: Probably this patch should fix it. Please try. -- Alexander. | http://www.yars.free.net/~lav/
diff
(text/plain, 2.3 KB)
Index: Timer.cc
===================================================================
RCS file: /home/lav/cvsroot/lftp/src/Timer.cc,v
retrieving revision 1.15
diff -u -p -r1.15 Timer.cc
--- Timer.cc 14 Jun 2006 05:35:32 -0000 1.15
+++ Timer.cc 4 Aug 2006 06:59:45 -0000
@@ -107,15 +107,19 @@ void Timer::init()
next_all=chain_all;
chain_all=this;
}
-Timer::~Timer()
+void Timer::remove_from_running_list()
{
- infty_count-=IsInfty();
if(next_running)
next_running->prev_running=prev_running;
if(prev_running)
prev_running->next_running=next_running;
if(chain_running==this)
chain_running=next_running;
+}
+Timer::~Timer()
+{
+ remove_from_running_list();
+ infty_count-=IsInfty();
Timer **scan=&chain_all;
while(*scan!=this)
scan=&scan[0]->next_all;
@@ -159,15 +163,16 @@ void Timer::re_sort()
// find new location in the list.
Timer *new_next=next_running;
Timer *new_prev=prev_running;
+
if(prev_running==0 && next_running==0 && chain_running!=this)
- new_next=chain_running;
+ new_next=chain_running; // it was not in the running list.
else if((!prev_running || prev_running->stop<stop)
&& (!next_running || stop<next_running->stop))
- return;
- if(next_running)
- next_running->prev_running=prev_running;
- if(prev_running)
- prev_running->next_running=next_running;
+ return; // it was already properly sorted.
+
+ remove_from_running_list();
+
+ // find new position in the list.
while(new_next && new_next->stop<stop)
{
new_prev=new_next;
@@ -178,6 +183,8 @@ void Timer::re_sort()
new_next=new_prev;
new_prev=new_prev->prev_running;
}
+
+ // re-insert it.
next_running=new_next;
prev_running=new_prev;
if(new_next)
Index: Timer.h
===================================================================
RCS file: /home/lav/cvsroot/lftp/src/Timer.h,v
retrieving revision 1.12
diff -u -p -r1.12 Timer.h
--- Timer.h 14 Jun 2006 05:35:32 -0000 1.12
+++ Timer.h 4 Aug 2006 07:00:09 -0000
@@ -38,6 +38,7 @@ class Timer
static Timer *chain_running;
Timer *next_running;
Timer *prev_running;
+ void remove_from_running_list();
void re_sort();
void set_last_setting(const TimeInterval &);
void init();