From b05ab854ae9b5ecc179a4075ee8d7953d42ffd2b Mon Sep 17 00:00:00 2001
From: Matt Johnston <matt@ucc.asn.au>
Date: Wed, 25 Jan 2006 17:13:38 +0000
Subject: [PATCH] Check that the output circular buffer is actually empty
 before closing the channel (thanks to Tomas Vanek for his help).

--HG--
extra : convert_revision : 7fb3ca52f21072127c9615a5bdbc054c24669e51
---
 common-channel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common-channel.c b/common-channel.c
index 7e8d4284..4bed78d0 100644
--- a/common-channel.c
+++ b/common-channel.c
@@ -377,7 +377,7 @@ static void writechannel(struct Channel* channel, int fd, circbuffer *cbuf) {
 	cbuf_incrread(cbuf, len);
 	channel->recvdonelen += len;
 
-	if (fd == channel->writefd && len == maxlen && channel->recveof) { 
+	if (fd == channel->writefd && cbuf_getused(cbuf) == 0 && channel->recveof) { 
 		/* Check if we're closing up */
 		closewritefd(channel);
 		TRACE(("leave writechannel: recveof set"))
-- 
GitLab