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
This commit is contained in:
Jilles Tjoelker 2008-04-13 00:44:21 +02:00
parent ec9738cbd8
commit dcb90e0d86
2 changed files with 7 additions and 30 deletions

View File

@ -46,7 +46,6 @@ typedef struct _buf_line
{
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? */

View File

@ -368,7 +368,6 @@ rb_linebuf_parse(buf_head_t * bufhead, char *data, int len, int raw)
{
/* 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);
@ -739,12 +738,9 @@ rb_linebuf_flush(rb_fde_t *F, buf_head_t * bufhead)
}
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
{
@ -777,29 +773,18 @@ rb_linebuf_flush(rb_fde_t *F, buf_head_t * bufhead)
{
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;
@ -825,13 +810,6 @@ rb_linebuf_flush(rb_fde_t *F, buf_head_t * bufhead)
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);