From: Ian Jackson Date: Fri, 30 Apr 2010 23:25:19 +0000 (+0100) Subject: Better message for 503 from peer on idle conn. Conventional macro protection for... X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=inn-innduct.git;a=commitdiff_plain;h=2956dfa1fbb33a617d7d7c266559df0884ca5577 Better message for 503 from peer on idle conn. Conventional macro protection for peer_rd_ok macros --- diff --git a/backends/innduct.c b/backends/innduct.c index 6060ebd..813091f 100644 --- a/backends/innduct.c +++ b/backends/innduct.c @@ -1715,15 +1715,18 @@ static void *peer_rd_ok(oop_source *lp, oop_read *oread, oop_rd_event ev, return OOP_CONTINUE; } + int conn_busy= + conn->waiting.count || + conn->priority.count || + conn->sent.count || + conn->xmitu; + if (conn->quitting) { if (code!=205 && code!=503) { connfail(conn, "peer gave unexpected response to QUIT: %s", sani); } else { - notice("C%d idle connection closed", conn->fd); - assert(!conn->waiting.count); - assert(!conn->priority.count); - assert(!conn->sent.count); - assert(!conn->xmitu); + notice("C%d idle connection closed by us", conn->fd); + assert(!conn_busy); LIST_REMOVE(conns,conn); conn_dispose(conn); } @@ -1733,25 +1736,36 @@ static void *peer_rd_ok(oop_source *lp, oop_read *oread, oop_rd_event ev, conn->since_activity= 0; Article *art; -#define GET_ARTICLE(musthavesent) \ - art= article_reply_check(conn, data, code_streaming, musthavesent, sani); \ - if (art) ; else return OOP_CONTINUE /* reply_check has failed the conn */ +#define GET_ARTICLE(musthavesent) do{ \ + art= article_reply_check(conn, data, code_streaming, musthavesent, sani); \ + if (!art) return OOP_CONTINUE; /* reply_check has failed the conn */ \ + }while(0) -#define ARTICLE_DEALTWITH(streaming,musthavesent,how) \ - code_streaming= (streaming); \ - GET_ARTICLE(musthavesent); \ - article_done(conn, art, RC_##how); break; +#define ARTICLE_DEALTWITH(streaming,musthavesent,how) do{ \ + code_streaming= (streaming); \ + GET_ARTICLE(musthavesent); \ + article_done(conn, art, RC_##how); \ + goto dealtwith; \ + }while(0) -#define PEERBADMSG(m) connfail(conn, m ": %s", sani); return OOP_CONTINUE +#define PEERBADMSG(m) do { \ + connfail(conn, m ": %s", sani); return OOP_CONTINUE; \ + }while(0) int code_streaming= 0; switch (code) { case 400: PEERBADMSG("peer stopped accepting articles"); - case 503: PEERBADMSG("peer timed us out"); default: PEERBADMSG("peer sent unexpected message"); + case 503: + if (conn_busy) PEERBADMSG("peer timed us out"); + notice("C%d idle connection closed by peer", conn->fd); + LIST_REMOVE(conns,conn); + conn_dispose(conn); + return OOP_CONTINUE; + case 435: ARTICLE_DEALTWITH(0,0,unwanted); /* IHAVE says they have it */ case 438: ARTICLE_DEALTWITH(1,0,unwanted); /* CHECK/TAKETHIS: they have it */ @@ -1783,6 +1797,7 @@ static void *peer_rd_ok(oop_source *lp, oop_read *oread, oop_rd_event ev, break; } +dealtwith: conn_maybe_write(conn); check_assign_articles(); @@ -2048,7 +2063,7 @@ static void *filemon_inotify_readable(oop_source *lp, int fd, die("inotify read %d bytes wanted struct of %d", r, (int)sizeof(iev)); } InputFile *ipf= filemon_inotify_wd2ipf[iev.wd]; - debug("filemon inotify readable read %d wd=%p", iev.wd, ipf); + debug("filemon inotify readable read %p wd=%d", ipf, iev.wd); filemon_callback(ipf); } return OOP_CONTINUE;