Skip to content

Commit 597e2ee

Browse files
committed
Increase socket buffer size
1 parent ae0efde commit 597e2ee

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

contrib/multimaster/dtmd/include/limits.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
#define BUFFER_SIZE (256 * 1024)
77
#define LISTEN_QUEUE_SIZE 100
88
#define MAX_STREAMS 4096
9+
#define SOCKET_BUFFER_SIZE (16*1024*1024)
910

1011
#endif

contrib/multimaster/dtmd/src/server.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ static int create_listening_socket(const char *host, int port) {
8181
int optval = 1;
8282
setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (char const*)&optval, sizeof(optval));
8383
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char const*)&optval, sizeof(optval));
84+
optval = SOCKET_BUFFER_SIZE;
85+
setsockopt(s, SOL_SOCKET, SO_SNDBUF, (const char*) &optval, sizeof(int));
86+
optval = SOCKET_BUFFER_SIZE;
87+
setsockopt(s, SOL_SOCKET, SO_RCVBUF, (const char*) &optval, sizeof(int));
8488

8589
struct sockaddr_in addr;
8690
addr.sin_family = AF_INET;

contrib/multimaster/sockhub/sockhub.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
#include "sockhub.h"
2121

22+
const size_t SOCKHUB_BUFFER_SIZE (16*1024*1024)
23+
2224
void ShubAddSocket(Shub* shub, int fd);
2325

2426
inline void ShubAddSocket(Shub* shub, int fd)
@@ -189,6 +191,10 @@ static void reconnect(Shub* shub)
189191
} else {
190192
int optval = 1;
191193
setsockopt(shub->output, IPPROTO_TCP, TCP_NODELAY, (char const*)&optval, sizeof(optval));
194+
optval = SOCKHUB_BUFFER_SIZE;
195+
setsockopt(shub->output, SOL_SOCKET, SO_SNDBUF, (const char*) &optval, sizeof(int));
196+
optval = SOCKHUB_BUFFER_SIZE;
197+
setsockopt(shub->output, SOL_SOCKET, SO_RCVBUF, (const char*) &optval, sizeof(int));
192198

193199
ShubAddSocket(shub, shub->output);
194200
if (sep != NULL) {

0 commit comments

Comments
 (0)