diff options
| author | Quentin Young <qlyoung@nvidia.com> | 2021-04-26 18:42:12 -0400 |
|---|---|---|
| committer | Quentin Young <qlyoung@nvidia.com> | 2021-04-29 12:12:32 -0400 |
| commit | fe2e3bae6a2207f97437c84f8a7525a7b31f38d6 (patch) | |
| tree | 05331b11b47a0972142038c3dbf0ed37ef3a8797 | |
| parent | 55ea3f2ec50c262dca3f789251a5de6ab7717bbb (diff) | |
Revert "bgpd: improve socket read performance"
This reverts commit 97a16e648115919aab3784a6511807e35c20ee20.
| -rw-r--r-- | bgpd/bgp_io.c | 8 |
1 files changed, 7 insertions, 1 deletions
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; |
