Commits

Jilles Tjoelker  committed dd35f08

Remove linebuf's per-line flushing flag, as it's per-head state.
In rare cases, this sharing caused the ircd to skip
part of outgoing traffic, e.g. appearing as "not enough
parameters" errors on the other side.
The purpose of this flag can be fulfilled by the writeofs
in the bufhead.
libratbox r25227

  • Participants
  • Parent commits 5f26a1b

Comments (0)

Files changed (2)

File libratbox/include/rb_linebuf.h

 {
 	char buf[BUF_DATA_SIZE + 2];
 	rb_uint8_t terminated;	/* Whether we've terminated the buffer */
-	rb_uint8_t flushing;	/* Whether we're flushing .. */
 	rb_uint8_t raw;	/* Whether this linebuf may hold 8-bit data */
 	int len;		/* How much data we've got */
 	int refcount;		/* how many linked lists are we in? */

File libratbox/src/linebuf.c

 	{
 		/* Check we're doing the partial buffer thing */
 		bufline = bufhead->list.tail->data;
-		lrb_assert(!bufline->flushing);
 		/* just try, the worst it could do is *reject* us .. */
 		if(!raw)
 			cpylen = rb_linebuf_copy_line(bufhead, bufline, data, len);
 
 		}
 
-		if(bufline->flushing)
-		{
-			vec[x].iov_base = bufline->buf + bufhead->writeofs;
-			vec[x++].iov_len = bufline->len - bufhead->writeofs;
-			ptr = ptr->next;
-		}
+		vec[x].iov_base = bufline->buf + bufhead->writeofs;
+		vec[x++].iov_len = bufline->len - bufhead->writeofs;
+		ptr = ptr->next;
 
 		do
 		{
 		{
 			bufline = ptr->data;
 
-			if(bufline->flushing)
+			if(xret >= bufline->len - bufhead->writeofs)
 			{
-				if(xret >= bufline->len - bufhead->writeofs)
-				{
-					xret = xret - (bufline->len - bufhead->writeofs);
-					ptr = ptr->next;
-					rb_linebuf_done_line(bufhead, bufline, bufhead->list.head);
-					continue;
-				}	
-			}
-			if(xret >= bufline->len) 
-			{
-				xret = xret - bufline->len;
+				xret -= bufline->len - bufhead->writeofs;
 				ptr = ptr->next;
 				rb_linebuf_done_line(bufhead, bufline, bufhead->list.head);
+				bufhead->writeofs = 0;
 			}
 			else 
 			{
-				bufline->flushing = 1;
-				bufhead->writeofs = xret;
+				bufhead->writeofs += xret;
 				break;
 			}
-			
 		}
 
 		return retval;
 		return -1;
 	}
 
-	/* Check we're flushing the first buffer */
-	if(!bufline->flushing)
-	{
-		bufline->flushing = 1;
-		bufhead->writeofs = 0;
-	}
-
 	/* Now, try writing data */
 	retval = rb_write(F, bufline->buf + bufhead->writeofs, bufline->len - bufhead->writeofs);