Browse Source

Return possible error message in the http result. Log the error in the

tracker code.
master
Richard Nyberg 19 years ago
parent
commit
2ee5eed062
3 changed files with 6 additions and 4 deletions
  1. +2
    -4
      btpd/http.c
  2. +1
    -0
      btpd/http.h
  3. +3
    -0
      btpd/tracker_req.c

+ 2
- 4
btpd/http.c View File

@@ -111,10 +111,8 @@ http_td_cb(void *arg)
struct http *h = arg; struct http *h = arg;
if (h->res.res == HRES_OK) if (h->res.res == HRES_OK)
curl_easy_getinfo(h->curlh, CURLINFO_RESPONSE_CODE, &h->res.code); 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) if (h->state != HS_CANCEL)
h->cb(h, &h->res, h->cb_arg); h->cb(h, &h->res, h->cb_arg);
curl_easy_cleanup(h->curlh); curl_easy_cleanup(h->curlh);


+ 1
- 0
btpd/http.h View File

@@ -12,6 +12,7 @@ enum http_status {
struct http_res { struct http_res {
enum http_status res; enum http_status res;
long code; long code;
const char *errmsg;
char *content; char *content;
size_t length; size_t length;
}; };


+ 3
- 0
btpd/tracker_req.c View File

@@ -141,6 +141,9 @@ http_cb(struct http *req, struct http_res *res, void *arg)
tr->ttype = TIMER_INTERVAL; tr->ttype = TIMER_INTERVAL;
event_add(&tr->timer, (& (struct timeval) { tr->interval, 0 })); event_add(&tr->timer, (& (struct timeval) { tr->interval, 0 }));
} else { } 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->nerrors++;
tr->ttype = TIMER_RETRY; tr->ttype = TIMER_RETRY;
event_add(&tr->timer, RETRY_WAIT); event_add(&tr->timer, RETRY_WAIT);


Loading…
Cancel
Save