Revert "bgpd: improve socket read performance"

This reverts commit 97a16e6481.
This commit is contained in:
Quentin Young 2021-04-26 18:42:12 -04:00
parent 55ea3f2ec5
commit fe2e3bae6a

View File

@ -462,10 +462,13 @@ done : {
*/
static uint16_t bgp_read(struct peer *peer, int *code_p)
{
size_t readsize; // how many bytes we want to read
ssize_t nbytes; // how many bytes we actually read
uint16_t status = 0;
uint8_t ibw[peer->max_packet_size * BGP_READ_PACKET_MAX];
nbytes = ringbuf_read(peer->ibuf_work, peer->fd);
readsize = MIN(ringbuf_space(peer->ibuf_work), sizeof(ibw));
nbytes = read(peer->fd, ibw, readsize);
/* EAGAIN or EWOULDBLOCK; come back later */
if (nbytes < 0 && ERRNO_IO_RETRY(errno)) {
@ -493,6 +496,9 @@ static uint16_t bgp_read(struct peer *peer, int *code_p)
*code_p = TCP_connection_closed;
SET_FLAG(status, BGP_IO_FATAL_ERR);
} else {
assert(ringbuf_put(peer->ibuf_work, ibw, nbytes)
== (size_t)nbytes);
}
return status;