]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-6735
authorBrian West <brian@freeswitch.org>
Fri, 22 Aug 2014 21:39:45 +0000 (16:39 -0500)
committerBrian West <brian@freeswitch.org>
Fri, 22 Aug 2014 21:39:52 +0000 (16:39 -0500)
src/include/switch_apr.h
src/mod/event_handlers/mod_event_socket/mod_event_socket.c
src/switch_apr.c

index c723a533e391fc0ea8ea274b1f544d8b0771b650..50096d5affad798d2d4bcdfeb58ae7847c042a0f 100644 (file)
@@ -985,6 +985,8 @@ SWITCH_DECLARE(switch_status_t) switch_thread_create(switch_thread_t ** new_thre
 #define SWITCH_SO_RCVBUF 128
 #define SWITCH_SO_DISCONNECTED 256
 #define SWITCH_SO_TCP_NODELAY 512
+#define SWITCH_SO_TCP_KEEPIDLE 520
+#define SWITCH_SO_TCP_KEEPINTVL 530
 
 
  /**
index 3ad1b0c96627cf307f724f8d7b9bb71c651161af..99a64154691cea4ad834a2b366199826f50ed00b 100644 (file)
@@ -446,6 +446,8 @@ SWITCH_STANDARD_APP(socket_function)
 
        switch_socket_opt_set(new_sock, SWITCH_SO_KEEPALIVE, 1);
        switch_socket_opt_set(new_sock, SWITCH_SO_TCP_NODELAY, 1);
+       switch_socket_opt_set(new_sock, SWITCH_SO_TCP_KEEPIDLE, 30);
+       switch_socket_opt_set(new_sock, SWITCH_SO_TCP_KEEPINTVL, 30);
 
        if (switch_socket_connect(new_sock, sa) != SWITCH_STATUS_SUCCESS) {
                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Socket Error!\n");
index a12ae2ddeb6d7e228df350650578f488f1921e58..e77be82897c07a146ab4c845a9769d8af8ed1149 100644 (file)
@@ -789,6 +789,34 @@ SWITCH_DECLARE(switch_status_t) switch_sockaddr_info_get(switch_sockaddr_t ** sa
 
 SWITCH_DECLARE(switch_status_t) switch_socket_opt_set(switch_socket_t *sock, int32_t opt, int32_t on)
 {
+       if (opt == SWITCH_SO_TCP_KEEPIDLE) {
+               int r = -10;
+               
+#if defined(TCP_KEEPIDLE)
+               r = setsockopt(jsock->client_socket, SOL_TCP, TCP_KEEPIDLE, (void *)&on, sizeof(on));
+#endif
+               if (r == -10) {
+                       return SWITCH_STATUS_NOTIMPL;
+               }
+
+       
+               return r ? SWITCH_STATUS_FALSE : SWITCH_STATUS_SUCCESS;
+       }
+
+       if (opt == SWITCH_SO_TCP_KEEPINTVL) {
+               int r = -10;
+
+#if defined(TCP_KEEPINTVL)
+               r = setsockopt(jsock->client_socket, SOL_TCP, TCP_KEEPINTVL, (void *)&on, sizeof(on));
+#endif
+
+               if (r == -10) {
+                       return SWITCH_STATUS_NOTIMPL;
+               }
+
+               return r ? SWITCH_STATUS_FALSE : SWITCH_STATUS_SUCCESS;
+       }
+
        return apr_socket_opt_set(sock, opt, on);
 }