From 630f11d18b48bab923394219a38b4d073dca8fb7 Mon Sep 17 00:00:00 2001 From: Richard Nyberg Date: Sat, 19 May 2007 15:53:07 +0000 Subject: I had missed a check for tracker errors. When a torrent is stopping it's supposed to stop if it can't contact the tracker in STOP_ERRORS tries. --- btpd/tracker_req.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/btpd/tracker_req.c b/btpd/tracker_req.c index 3f3a8be..61425cb 100644 --- a/btpd/tracker_req.c +++ b/btpd/tracker_req.c @@ -97,6 +97,16 @@ tr_cancel(struct tracker *tr) tr->req = NULL; } +static void +tr_set_stopped(struct torrent *tp) +{ + struct tracker *tr = tp->tr; + btpd_ev_del(&tr->timer); + tr->ttype = TIMER_NONE; + if (tr->req != NULL) + tr_cancel(tr); +} + static void tr_send(struct torrent *tp, enum tr_event event) { @@ -117,8 +127,12 @@ tr_send(struct torrent *tp, enum tr_event event) if ((op == NULL || (tr->req = op->request(tp, event, get_url(tr))) == NULL)) { - next_url(tr); tr->nerrors++; + if (tr->event == TR_EV_STOPPED && tr->nerrors >= STOP_ERRORS) { + tr_set_stopped(tp); + return; + } + next_url(tr); tr->ttype = TIMER_RETRY; btpd_ev_add(&tr->timer, (& (struct timeval) { 5, 0 })); } else { @@ -128,16 +142,6 @@ tr_send(struct torrent *tp, enum tr_event event) } } -static void -tr_set_stopped(struct torrent *tp) -{ - struct tracker *tr = tp->tr; - btpd_ev_del(&tr->timer); - tr->ttype = TIMER_NONE; - if (tr->req != NULL) - tr_cancel(tr); -} - void tr_result(struct torrent *tp, enum tr_res res, int interval) { -- cgit 1.4.1