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:
parent
ec9738cbd8
commit
dcb90e0d86
|
@ -46,7 +46,6 @@ typedef struct _buf_line
|
||||||
{
|
{
|
||||||
char buf[BUF_DATA_SIZE + 2];
|
char buf[BUF_DATA_SIZE + 2];
|
||||||
rb_uint8_t terminated; /* Whether we've terminated the buffer */
|
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 */
|
rb_uint8_t raw; /* Whether this linebuf may hold 8-bit data */
|
||||||
int len; /* How much data we've got */
|
int len; /* How much data we've got */
|
||||||
int refcount; /* how many linked lists are we in? */
|
int refcount; /* how many linked lists are we in? */
|
||||||
|
|
|
@ -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 */
|
/* Check we're doing the partial buffer thing */
|
||||||
bufline = bufhead->list.tail->data;
|
bufline = bufhead->list.tail->data;
|
||||||
lrb_assert(!bufline->flushing);
|
|
||||||
/* just try, the worst it could do is *reject* us .. */
|
/* just try, the worst it could do is *reject* us .. */
|
||||||
if(!raw)
|
if(!raw)
|
||||||
cpylen = rb_linebuf_copy_line(bufhead, bufline, data, len);
|
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;
|
||||||
vec[x].iov_base = bufline->buf + bufhead->writeofs;
|
ptr = ptr->next;
|
||||||
vec[x++].iov_len = bufline->len - bufhead->writeofs;
|
|
||||||
ptr = ptr->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -777,29 +773,18 @@ rb_linebuf_flush(rb_fde_t *F, buf_head_t * bufhead)
|
||||||
{
|
{
|
||||||
bufline = ptr->data;
|
bufline = ptr->data;
|
||||||
|
|
||||||
if(bufline->flushing)
|
if(xret >= bufline->len - bufhead->writeofs)
|
||||||
{
|
{
|
||||||
if(xret >= bufline->len - bufhead->writeofs)
|
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;
|
|
||||||
ptr = ptr->next;
|
ptr = ptr->next;
|
||||||
rb_linebuf_done_line(bufhead, bufline, bufhead->list.head);
|
rb_linebuf_done_line(bufhead, bufline, bufhead->list.head);
|
||||||
|
bufhead->writeofs = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bufline->flushing = 1;
|
bufhead->writeofs += xret;
|
||||||
bufhead->writeofs = xret;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
|
@ -825,13 +810,6 @@ rb_linebuf_flush(rb_fde_t *F, buf_head_t * bufhead)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check we're flushing the first buffer */
|
|
||||||
if(!bufline->flushing)
|
|
||||||
{
|
|
||||||
bufline->flushing = 1;
|
|
||||||
bufhead->writeofs = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Now, try writing data */
|
/* Now, try writing data */
|
||||||
retval = rb_write(F, bufline->buf + bufhead->writeofs, bufline->len - bufhead->writeofs);
|
retval = rb_write(F, bufline->buf + bufhead->writeofs, bufline->len - bufhead->writeofs);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue