about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRichard Nyberg <rnyberg@murmeldjur.se>2006-02-05 11:24:10 +0000
committerRichard Nyberg <rnyberg@murmeldjur.se>2006-02-05 11:24:10 +0000
commit886fb651d8666d6fad9c847b93cf43cf945e25c6 (patch)
treeff6f68186569c4eda941a0b314595e3c80bb6138
parent2528d4ad73a73d1603ad6756a5ddde11c8d82e6d (diff)
downloadbtpd-886fb651d8666d6fad9c847b93cf43cf945e25c6.tar.gz
btpd-886fb651d8666d6fad9c847b93cf43cf945e25c6.zip
Add function to get tracker error count. Don't look for peers and stuff
in tracker replies when we're stopping.

-rw-r--r--btpd/tracker_req.c11
-rw-r--r--btpd/tracker_req.h1
2 files changed, 10 insertions, 2 deletions
diff --git a/btpd/tracker_req.c b/btpd/tracker_req.c
index 5325a3d..74b16ee 100644
--- a/btpd/tracker_req.c
+++ b/btpd/tracker_req.c
@@ -130,8 +130,9 @@ http_cb(struct http *req, struct http_res *res, void *arg)
     struct tracker *tr = tp->tr;
     assert(tr->ttype == TIMER_TIMEOUT);
     tr->req = NULL;
-    if ((http_succeeded(res) &&
-            parse_reply(tp, res->content, res->length) == 0)) {
+    if (res->res == HRES_OK &&
+        (tr->event == TR_EV_STOPPED
+            || parse_reply(tp, res->content, res->length) == 0)) {
         tr->nerrors = 0;
         tr->ttype = TIMER_INTERVAL;
         event_add(&tr->timer, (& (struct timeval) { tr->interval, 0 }));
@@ -249,3 +250,9 @@ tr_stop(struct torrent *tp)
 {
     tr_send(tp, TR_EV_STOPPED);
 }
+
+unsigned
+tr_errors(struct torrent *tp)
+{
+    return tp->tr->nerrors;
+}
diff --git a/btpd/tracker_req.h b/btpd/tracker_req.h
index 95cc170..6106ef7 100644
--- a/btpd/tracker_req.h
+++ b/btpd/tracker_req.h
@@ -6,5 +6,6 @@ void tr_stop(struct torrent *tp);
 void tr_refresh(struct torrent *tp);
 void tr_complete(struct torrent *tp);
 void tr_destroy(struct torrent *tp);
+unsigned tr_errors(struct torrent *tp);
 
 #endif