Skip to content

Commit

Permalink
lib: Allow setsockopt functions to return size set
Browse files Browse the repository at this point in the history
When finding a send/receive buffer size that is usable
let's report how big we were able to set it.

Signed-off-by: Donald Sharp <[email protected]>
  • Loading branch information
donaldsharp committed Dec 3, 2024
1 parent 267dc19 commit d5615fd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions lib/sockopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#define HAVE_BSD_STRUCT_IP_MREQ_HACK
#endif

void setsockopt_so_recvbuf(int sock, int size)
int setsockopt_so_recvbuf(int sock, int size)
{
int orig_req = size;

Expand All @@ -34,9 +34,11 @@ void setsockopt_so_recvbuf(int sock, int size)
flog_err(EC_LIB_SOCKET,
"%s: fd %d: SO_RCVBUF set to %d (requested %d)",
__func__, sock, size, orig_req);

return size;
}

void setsockopt_so_sendbuf(const int sock, int size)
int setsockopt_so_sendbuf(const int sock, int size)
{
int orig_req = size;

Expand All @@ -51,6 +53,8 @@ void setsockopt_so_sendbuf(const int sock, int size)
flog_err(EC_LIB_SOCKET,
"%s: fd %d: SO_SNDBUF set to %d (requested %d)",
__func__, sock, size, orig_req);

return size;
}

int getsockopt_so_sendbuf(const int sock)
Expand Down
4 changes: 2 additions & 2 deletions lib/sockopt.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
extern "C" {
#endif

extern void setsockopt_so_recvbuf(int sock, int size);
extern void setsockopt_so_sendbuf(const int sock, int size);
extern int setsockopt_so_recvbuf(int sock, int size);
extern int setsockopt_so_sendbuf(const int sock, int size);
extern int getsockopt_so_sendbuf(const int sock);
extern int getsockopt_so_recvbuf(const int sock);

Expand Down

0 comments on commit d5615fd

Please sign in to comment.