diff options
author | Sander Vrijders <[email protected]> | 2018-05-03 12:10:02 +0200 |
---|---|---|
committer | Dimitri Staessens <[email protected]> | 2018-05-03 12:26:48 +0200 |
commit | 12968ba98642bd7057e8e7f41e184ab2d61671ed (patch) | |
tree | 8f3e3706bc8038f795d6f5b758b46126787dde9f /src/lib/sockets.c | |
parent | 711777a4c7665db2d7ec8d05105eee29054c8562 (diff) | |
download | ouroboros-12968ba98642bd7057e8e7f41e184ab2d61671ed.tar.gz ouroboros-12968ba98642bd7057e8e7f41e184ab2d61671ed.zip |
lib: Make UNIX socket buffer size configurable0.11.3
This makes the buffer size used by the UNIX sockets configurable. In
case of a lot of IPCPs in the system it might become too small with
the default value, resulting in irm command failures. The user can now
easily configure it with an adequate value.
Signed-off-by: Sander Vrijders <[email protected]>
Signed-off-by: Dimitri Staessens <[email protected]>
Diffstat (limited to 'src/lib/sockets.c')
-rw-r--r-- | src/lib/sockets.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/lib/sockets.c b/src/lib/sockets.c index 6e7d4ad5..b148b7ca 100644 --- a/src/lib/sockets.c +++ b/src/lib/sockets.c @@ -33,12 +33,19 @@ #include <stdbool.h> #include <sys/time.h> +/* Apple doesn't support SEQPACKET. */ +#ifdef __APPLE__ +#define SOCK_TYPE SOCK_STREAM +#else +#define SOCK_TYPE SOCK_SEQPACKET +#endif + int client_socket_open(char * file_name) { int sockfd; struct sockaddr_un serv_addr; - sockfd = socket(AF_UNIX, SOCK_SEQPACKET, 0); + sockfd = socket(AF_UNIX, SOCK_TYPE, 0); if (sockfd < 0) return -1; @@ -66,7 +73,7 @@ int server_socket_open(char * file_name) return -1; } - sockfd = socket(AF_UNIX, SOCK_SEQPACKET, 0); + sockfd = socket(AF_UNIX, SOCK_TYPE, 0); if (sockfd < 0) return -1; @@ -96,7 +103,7 @@ static void close_ptr(void * o) irm_msg_t * send_recv_irm_msg(irm_msg_t * msg) { int sockfd; - uint8_t buf[IRM_MSG_BUF_SIZE]; + uint8_t buf[SOCK_BUF_SIZE]; ssize_t len; irm_msg_t * recv_msg = NULL; @@ -115,7 +122,7 @@ irm_msg_t * send_recv_irm_msg(irm_msg_t * msg) irm_msg__pack(msg, buf); if (write(sockfd, buf, len) != -1) - len = read(sockfd, buf, IRM_MSG_BUF_SIZE); + len = read(sockfd, buf, SOCK_BUF_SIZE); if (len > 0) recv_msg = irm_msg__unpack(NULL, len, buf); |