about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRichard Nyberg <rnyberg@murmeldjur.se>2006-02-11 16:52:56 +0000
committerRichard Nyberg <rnyberg@murmeldjur.se>2006-02-11 16:52:56 +0000
commit2ee5eed0623127c14df712df7187d41929725235 (patch)
tree9dc47f44c04284c3b0eaf31920f3798919cba608
parent61752ade717c21044f83dfc09cfed8c4d54e2f67 (diff)
downloadbtpd-2ee5eed0623127c14df712df7187d41929725235.tar.gz
btpd-2ee5eed0623127c14df712df7187d41929725235.zip
Return possible error message in the http result. Log the error in the
tracker code.

-rw-r--r--btpd/http.c6
-rw-r--r--btpd/http.h1
-rw-r--r--btpd/tracker_req.c3
3 files changed, 6 insertions, 4 deletions
diff --git a/btpd/http.c b/btpd/http.c
index cd42cfb..9f57212 100644
--- a/btpd/http.c
+++ b/btpd/http.c
@@ -111,10 +111,8 @@ http_td_cb(void *arg)
     struct http *h = arg;
     if (h->res.res == HRES_OK)
         curl_easy_getinfo(h->curlh, CURLINFO_RESPONSE_CODE, &h->res.code);
-    if (h->res.res == HRES_FAIL) {
-        btpd_log(BTPD_L_ERROR, "Http error for url '%s' (%s).\n", h->url,
-            curl_easy_strerror(h->res.code));
-    }
+    if (h->res.res == HRES_FAIL)
+        h->res.errmsg = curl_easy_strerror(h->res.code);
     if (h->state != HS_CANCEL)
         h->cb(h, &h->res, h->cb_arg);
     curl_easy_cleanup(h->curlh);
diff --git a/btpd/http.h b/btpd/http.h
index c0dc4f4..78861c6 100644
--- a/btpd/http.h
+++ b/btpd/http.h
@@ -12,6 +12,7 @@ enum http_status {
 struct http_res {
     enum http_status res;
     long code;
+    const char *errmsg;
     char *content;
     size_t length;
 };
diff --git a/btpd/tracker_req.c b/btpd/tracker_req.c
index e9e3e35..e55e0ed 100644
--- a/btpd/tracker_req.c
+++ b/btpd/tracker_req.c
@@ -141,6 +141,9 @@ http_cb(struct http *req, struct http_res *res, void *arg)
         tr->ttype = TIMER_INTERVAL;
         event_add(&tr->timer, (& (struct timeval) { tr->interval, 0 }));
     } else {
+        if (res->res == HRES_FAIL)
+            btpd_log(BTPD_L_BTPD, "Tracker request for '%s' failed (%s).\n",
+                torrent_name(tp), res->errmsg);
         tr->nerrors++;
         tr->ttype = TIMER_RETRY;
         event_add(&tr->timer, RETRY_WAIT);