about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRichard Nyberg <rnyberg@murmeldjur.se>2006-11-15 11:21:27 +0000
committerRichard Nyberg <rnyberg@murmeldjur.se>2006-11-15 11:21:27 +0000
commiteeb9d252e172e0f02cc94340a50ffe03495198e7 (patch)
tree4c84b816b0669ef62e2191b4b0e85c67357a46cb
parent68c4f99b29a758d29ec301e2de8236a88a55c6df (diff)
downloadbtpd-eeb9d252e172e0f02cc94340a50ffe03495198e7.tar.gz
btpd-eeb9d252e172e0f02cc94340a50ffe03495198e7.zip
Fix bug in get_op. Increase the tracker error counter, and reduce the timeout
for trying the next url, for url's that we can't use. The timeout is in this
case just there to keep btpd from busy looping on a bad url.

-rw-r--r--btpd/tracker_req.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/btpd/tracker_req.c b/btpd/tracker_req.c
index 2d2dbb1..3f3a8be 100644
--- a/btpd/tracker_req.c
+++ b/btpd/tracker_req.c
@@ -80,11 +80,11 @@ next_url(struct tracker *tr)
 struct tr_op *
 get_op(struct tracker *tr)
 {
-    struct tr_op *op;
+    struct tr_op **opp;
     char *url = get_url(tr);
-    for (op = m_tr_ops[0]; op != NULL; op++)
-        if (strncasecmp(op->scheme, url, op->len) == 0)
-            return op;
+    for (opp = m_tr_ops; *opp != NULL; opp++)
+        if (strncasecmp((*opp)->scheme, url, (*opp)->len) == 0)
+            return *opp;
     return NULL;
 }
 
@@ -118,8 +118,9 @@ 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++;
         tr->ttype = TIMER_RETRY;
-        btpd_ev_add(&tr->timer, (& (struct timeval) { 20, 0 }));
+        btpd_ev_add(&tr->timer, (& (struct timeval) { 5, 0 }));
     } else {
         m_tlast_req = btpd_seconds;
         tr->ttype = TIMER_TIMEOUT;