diff options
| author | Richard Nyberg <rnyberg@murmeldjur.se> | 2007-05-19 15:53:07 +0000 |
|---|---|---|
| committer | Richard Nyberg <rnyberg@murmeldjur.se> | 2007-05-19 15:53:07 +0000 |
| commit | 630f11d18b48bab923394219a38b4d073dca8fb7 (patch) | |
| tree | a0097eedf94568f0f193ee2406190c79742a5808 | |
| parent | f26afae21422a8d47af2087d8919c583816e4e19 (diff) | |
| download | btpd-630f11d18b48bab923394219a38b4d073dca8fb7.tar.gz btpd-630f11d18b48bab923394219a38b4d073dca8fb7.zip | |
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.
| -rw-r--r-- | btpd/tracker_req.c | 26 |
1 files 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 @@ -98,6 +98,16 @@ tr_cancel(struct tracker *tr) } 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) { struct tracker *tr = tp->tr; @@ -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) { |