summaryrefslogtreecommitdiff
path: root/infra/src/ctrlmsg.c
diff options
context:
space:
mode:
Diffstat (limited to 'infra/src/ctrlmsg.c')
-rw-r--r--infra/src/ctrlmsg.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/infra/src/ctrlmsg.c b/infra/src/ctrlmsg.c
index 6ad686c..a6f11f9 100644
--- a/infra/src/ctrlmsg.c
+++ b/infra/src/ctrlmsg.c
@@ -12,6 +12,7 @@
#include <arpa/inet.h>
#include <sys/epoll.h>
#include <sys/eventfd.h>
+#include <netinet/tcp.h>
#include <unistd.h>
#include <assert.h>
#include <fcntl.h>
@@ -464,6 +465,41 @@ static int __server_mode_create(struct ctrlmsg_handler * handle, struct sockaddr
goto out;
}
+ int tcp_keepalive = 1;
+ if (setsockopt(listen_fd, SOL_SOCKET, SO_KEEPALIVE, (const void*)&tcp_keepalive, sizeof(int)) < 0)
+ {
+ MR_ERROR("Set crash event listen fd keepalive failed : %s", strerror(errno));
+ goto out;
+ }
+
+ int tcp_keepcnt = 4;
+ if (setsockopt(listen_fd, IPPROTO_TCP, TCP_KEEPCNT, (const void*)&tcp_keepcnt, sizeof(int)) < 0)
+ {
+ MR_ERROR("Set crash event listen fd keepcnt failed : %s", strerror(errno));
+ goto out;
+ }
+
+ int tcp_keepintvl = 1;
+ if (setsockopt(listen_fd, IPPROTO_TCP, TCP_KEEPINTVL, (const void*)&tcp_keepintvl, sizeof(int)) < 0)
+ {
+ MR_ERROR("Set crash event listen fd keepintvl failed : %s", strerror(errno));
+ goto out;
+ }
+
+ int tcp_keepidle = 5;
+ if (setsockopt(listen_fd, IPPROTO_TCP, TCP_KEEPIDLE, (const void*)&tcp_keepidle, sizeof(int)) < 0)
+ {
+ MR_ERROR("Set crash event listen fd keepidle failed : %s", strerror(errno));
+ goto out;
+ }
+
+ int tcp_user_timeout = 300;
+ if (setsockopt(listen_fd, IPPROTO_TCP, TCP_USER_TIMEOUT, (const void*)&tcp_user_timeout, sizeof(int)) < 0)
+ {
+ MR_ERROR("Set crash event listen fd user timeout failed : %s", strerror(errno));
+ goto out;
+ }
+
ret = bind(listen_fd, (struct sockaddr *)&sockaddr_in, sizeof(struct sockaddr_in));
if (ret < 0)
{
@@ -642,4 +678,4 @@ void ctrlmsg_event_conn_close_register(struct ctrlmsg_handler * handler,
cb_object->arg = arg;
TAILQ_INSERT_TAIL(&handler->cb_conn_close_list, cb_object, next);
return;
-} \ No newline at end of file
+}