From 2ee5eed0623127c14df712df7187d41929725235 Mon Sep 17 00:00:00 2001 From: Richard Nyberg Date: Sat, 11 Feb 2006 16:52:56 +0000 Subject: [PATCH] Return possible error message in the http result. Log the error in the tracker code. --- btpd/http.c | 6 ++---- btpd/http.h | 1 + btpd/tracker_req.c | 3 +++ 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);