소스 검색

More tracker logging, and use switch for log type.

master
Richard Nyberg 16 년 전
부모
커밋
2d7d9c33af
3개의 변경된 파일21개의 추가작업 그리고 15개의 파일을 삭제
  1. +1
    -1
      btpd/btpd.h
  2. +12
    -2
      btpd/tracker_req.c
  3. +8
    -12
      btpd/util.c

+ 1
- 1
btpd/btpd.h 파일 보기

@@ -53,7 +53,7 @@

#define BTPD_L_ALL 0xffffffff
#define BTPD_L_ERROR 0x00000001
#define BTPD_L_TRACKER 0x00000002
#define BTPD_L_TR 0x00000002
#define BTPD_L_CONN 0x00000004
#define BTPD_L_MSG 0x00000008
#define BTPD_L_BTPD 0x00000010


+ 12
- 2
btpd/tracker_req.c 파일 보기

@@ -62,6 +62,8 @@ all_failed(struct tr_tier *t)
static void *
req_send(struct tr_tier *t)
{
btpd_log(BTPD_L_TR, "sending event %d to '%s' for '%s'.\n",
t->event, t->cur->url, torrent_name(t->tp));
switch (t->cur->type) {
case TR_HTTP:
return httptr_req(t->tp, t, t->cur->url, t->event);
@@ -166,8 +168,11 @@ add_tracker(struct tr_tier *t, const char *url)
if ((e->url = strdup(url)) == NULL)
btpd_err("Out of memory.\n");
e->type = TR_HTTP;
} else
} else {
btpd_log(BTPD_L_TR, "skipping unsupported tracker '%s' for '%s'.\n",
url, torrent_name(t->tp));
return;
}
BTPDQ_INSERT_TAIL(&t->trackers, e, entry);
}

@@ -175,11 +180,11 @@ static struct tr_tier *
tier_create(struct torrent *tp, struct mi_tier *tier)
{
struct tr_tier *t = btpd_calloc(1, sizeof(*t));
t->tp = tp;
BTPDQ_INIT(&t->trackers);
for (int i = 0; i < tier->nurls; i++)
add_tracker(t, tier->urls[i]);
if (!BTPDQ_EMPTY(&t->trackers)) {
t->tp = tp;
t->interval = -1;
t->event = TR_EV_STOPPED;
evtimer_init(&t->timer, tier_timer_cb, t);
@@ -292,6 +297,8 @@ tr_result(struct tr_tier *t, struct tr_response *res)
break;
}
case TR_RES_CONN:
btpd_log(BTPD_L_TR, "connection to '%s' failed for '%s'.\n",
t->cur->url, torrent_name(t->tp));
e = t->cur;
while ((e = BTPDQ_NEXT(e, entry)) != NULL && e->failure != NULL)
;
@@ -313,6 +320,9 @@ tr_result(struct tr_tier *t, struct tr_response *res)
btpd_log(BTPD_L_ERROR, "bad data from tracker '%s' for '%s'.\n",
t->cur->url, torrent_name(t->tp));
case TR_RES_OK:
if (TR_RES_OK)
btpd_log(BTPD_L_TR, "response from '%s' for '%s'.\n",
t->cur->url, torrent_name(t->tp));
if (t->event == TR_EV_STOPPED)
t->active = 0;
else {


+ 8
- 12
btpd/util.c 파일 보기

@@ -65,18 +65,14 @@ btpd_timer_del(struct timeout *to)
static const char *
logtype_str(uint32_t type)
{
if (type & BTPD_L_BTPD)
return "btpd";
else if (type & BTPD_L_ERROR)
return "error";
else if (type & BTPD_L_CONN)
return "conn";
else if (type & BTPD_L_TRACKER)
return "tracker";
else if (type & BTPD_L_MSG)
return "msg";
else
return "";
switch (type) {
case BTPD_L_BTPD: return "btpd";
case BTPD_L_ERROR: return "error";
case BTPD_L_CONN: return "conn";
case BTPD_L_TR: return "tracker";
case BTPD_L_MSG: return "msg";
}
return "";
}

static void


불러오는 중...
취소
저장