From fe2e3bae6a2207f97437c84f8a7525a7b31f38d6 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Mon, 26 Apr 2021 18:42:12 -0400 Subject: [PATCH] Revert "bgpd: improve socket read performance" This reverts commit 97a16e648115919aab3784a6511807e35c20ee20. --- bgpd/bgp_io.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bgpd/bgp_io.c b/bgpd/bgp_io.c index c2d8cae580..fec96700da 100644 --- a/bgpd/bgp_io.c +++ b/bgpd/bgp_io.c @@ -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; -- 2.39.5