From bf2c2c63389e40250828d9718db75028d120dee0 Mon Sep 17 00:00:00 2001 From: Richard Nyberg Date: Fri, 29 Jul 2005 20:19:04 +0000 Subject: Make sure we don't empty the outq and leave the write callback enabled. --- btpd/peer.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/btpd/peer.c b/btpd/peer.c index cc57a5d..c3de819 100644 --- a/btpd/peer.c +++ b/btpd/peer.c @@ -310,6 +310,8 @@ peer_on_cancel(struct peer *p, uint32_t index, uint32_t begin, uint32_t length) { struct nb_link *nl = BTPDQ_FIRST(&p->outq); + if (nl == NULL) + return; while (nl != NULL) { if (nl->nb->info.type == NB_PIECE && nl->nb->info.index == index @@ -327,6 +329,14 @@ peer_on_cancel(struct peer *p, uint32_t index, uint32_t begin, } nl = BTPDQ_NEXT(nl, entry); } + + if (BTPDQ_EMPTY(&p->outq)) { + if (p->flags & PF_ON_WRITEQ) { + BTPDQ_REMOVE(&btpd.writeq, p, wq_entry); + p->flags &= ~PF_ON_WRITEQ; + } else + event_del(&p->out_ev); + } } int -- cgit 1.4.1