Skip to content

Commit

Permalink
network: added function to set socket receiving buffer size
Browse files Browse the repository at this point in the history
Increasing socket receiving buffers can avoid losing datagram packets in case of a burst of incoming packets.
The value is capped by /proc/sys/net/core/rmem_max on Linux (rmem_default is the default value if flb_net_socket_rcv_buffer is not called).

Signed-off-by: Benoît GARNIER <[email protected]>
  • Loading branch information
ChezBunch authored and edsiper committed Nov 8, 2022
1 parent 4208622 commit 636e083
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/fluent-bit/flb_network.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ int flb_net_socket_reset(flb_sockfd_t fd);
int flb_net_socket_tcp_nodelay(flb_sockfd_t fd);
int flb_net_socket_blocking(flb_sockfd_t fd);
int flb_net_socket_nonblocking(flb_sockfd_t fd);
int flb_net_socket_rcv_buffer(flb_sockfd_t fd, int rcvbuf);
int flb_net_socket_tcp_fastopen(flb_sockfd_t sockfd);

/* Socket handling */
Expand Down
10 changes: 10 additions & 0 deletions src/flb_network.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,16 @@ int flb_net_socket_nonblocking(flb_sockfd_t fd)
return 0;
}

int flb_net_socket_rcv_buffer(flb_sockfd_t fd, int rcvbuf)
{
if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &rcvbuf, sizeof(rcvbuf)) != 0) {
flb_errno();
return -1;
}

return 0;
}

int flb_net_socket_blocking(flb_sockfd_t fd)
{
#ifdef _WIN32
Expand Down

0 comments on commit 636e083

Please sign in to comment.