commit b10c4aeed66718a4411b7695f326d5e9b081fd89
parent 2955d38f0ef209aa43ef5dcef04c8fb0fc287028
Author: sin <sin@2f30.org>
Date: Sun, 27 Dec 2015 18:00:38 +0000
unloadtorrent() removes torrent from list as well
Diffstat:
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/torrentd.c b/torrentd.c
@@ -868,6 +868,7 @@ loadtorrent(char *f)
char *p;
t = ecalloc(1, sizeof(*t));
+ TAILQ_INSERT_TAIL(&torrenthead, t, entry);
if (readfile(f, &t->buf, &t->buflen) < 0) {
warnx("failed to read %s", f);
goto fail;
@@ -1015,7 +1016,6 @@ loadtorrent(char *f)
calcinfohash(t);
- TAILQ_INSERT_TAIL(&torrenthead, t, entry);
return t;
fail:
unloadtorrent(t);
@@ -1030,6 +1030,7 @@ unloadtorrent(struct torrent *t)
if (!t)
return;
+ TAILQ_REMOVE(&torrenthead, t, entry);
i = t->nannouncers;
while (i--) {
j = t->announcers[i].len;