This commit is contained in:
Brian West 2014-08-22 16:39:45 -05:00
parent b6dc4a6c11
commit f4a04e65f2
3 changed files with 32 additions and 0 deletions

View 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
/**

View 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");

View 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);
}