X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=blobdiff_plain;f=backends%2Finnduct.c;h=561ff0022ff30e3d43130aa31e4bcc5ce4f56d6a;hb=f4edee10297eb6cf34c745a1a68ed796339abe5e;hp=11ab24243322223020c09405b1d83850ee141ede;hpb=7bad22cca02d17b67d442ecb8c28923438785738;p=inn-innduct.git diff --git a/backends/innduct.c b/backends/innduct.c index 11ab242..561ff00 100644 --- a/backends/innduct.c +++ b/backends/innduct.c @@ -23,6 +23,13 @@ * with GPLv3. If not then please let me know. -Ian Jackson.) */ +/* + * todo + * + * don't mind reconnecting if we just disconnected due to idle + * some weird disconnection event still investigating + */ + /* * Newsfeeds file entries should look like this: * host.name.of.site[/exclude,exclude,...]\ @@ -1119,7 +1126,7 @@ static void vconnfail(Conn *conn, const char *fmt, va_list al) { LIST_REMOVE(conns,conn); char *m= xvasprintf(fmt,al); - warn("C%d[%d] connection failed requeueing " RCI_TRIPLE_FMT_BASE ": %s", + warn("C%d (now %d) connection failed requeueing " RCI_TRIPLE_FMT_BASE ": %s", conn->fd, conns.count, RCI_TRIPLE_VALS_BASE(requeue, /*nothing*/), m); free(m); @@ -1300,7 +1307,7 @@ static void *connchild_event(oop_source *lp, int fd, oop_event e, void *u) { if (r) sysdie("oop_rd_read for peer (fd=%d)",conn->fd); LIST_ADDHEAD(conns, conn); - notice("C%d[%d] connected %s", + notice("C%d (now %d) connected %s", conn->fd, conns.count, conn->stream ? "streaming" : "plain"); connect_attempt_discard(); @@ -1663,15 +1670,18 @@ static void *conn_write_some_xmits(Conn *conn) { assert(rs > 0); int done; - for (done=0; rs && donexmitu; done++) { + for (done=0; rs; ) { + assert(donexmitu); struct iovec *vp= &conn->xmit[done]; XmitDetails *dp= &conn->xmitd[done]; - if (rs > vp->iov_len) { + if (rs >= vp->iov_len) { rs -= vp->iov_len; - xmit_free(dp); + xmit_free(dp); /* vp->iov_len -= vp->iov_len, etc. */ + done++; } else { vp->iov_base= (char*)vp->iov_base + rs; vp->iov_len -= rs; + break; /* rs -= rs */ } } int newu= conn->xmitu - done; @@ -1902,7 +1912,8 @@ static void *peer_rd_ok(oop_source *lp, oop_read *oread, oop_rd_event ev, connfail(conn, "peer gave unexpected response to QUIT: %s", sani); } else { LIST_REMOVE(conns,conn); - notice("C%d[%d] idle connection closed by us", conn->fd, conns.count); + notice("C%d (now %d) idle connection closed by us", + conn->fd, conns.count); assert(!conn_busy); conn_dispose(conn); } @@ -1939,7 +1950,8 @@ static void *peer_rd_ok(oop_source *lp, oop_read *oread, oop_rd_event ev, PEERBADMSG("peer timed us out or stopped accepting articles"); LIST_REMOVE(conns,conn); - notice("C%d[%d] idle connection closed by peer", conns.count, conn->fd); + notice("C%d (now %d) idle connection closed by peer", + conns.count, conn->fd); conn_dispose(conn); return OOP_CONTINUE;