增加读入USER_TIMEOUT TCP选项,修正timeout相关的setsockopt设置。

This commit is contained in:
Lu Qiuwen
2018-09-21 19:06:44 +08:00
parent 1a70d3948a
commit 7b6dbb06aa
8 changed files with 22 additions and 10 deletions

View File

@@ -67,7 +67,7 @@ static inline enum tfe_conn_dir __bev_dir(struct tfe_stream_private * _stream, s
return CONN_DIR_DOWNSTREAM;
}
if(_stream->conn_upstream && bev == _stream->conn_upstream->bev)
if (_stream->conn_upstream && bev == _stream->conn_upstream->bev)
{
return CONN_DIR_UPSTREAM;
}
@@ -840,7 +840,7 @@ void __stream_fd_option_setup(struct tfe_stream_private * _stream, evutil_socket
if (tcp_options->tcp_keepcnt > 0)
{
if (setsockopt(fd, SOL_SOCKET, TCP_KEEPCNT, (const void *) &tcp_options->tcp_keepcnt, sizeof(int)) == -1)
if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPCNT, (const void *) &tcp_options->tcp_keepcnt, sizeof(int)) == -1)
{
TFE_STREAM_LOG_ERROR(stream, "setsockopt(TCP_KEEPCNT, %d) failed, ignored: %s",
tcp_options->tcp_keepcnt, strerror(errno));
@@ -849,7 +849,7 @@ void __stream_fd_option_setup(struct tfe_stream_private * _stream, evutil_socket
if (tcp_options->tcp_keepintvl > 0)
{
if (setsockopt(fd, SOL_SOCKET, TCP_KEEPINTVL, (const void *) &tcp_options->tcp_keepintvl, sizeof(int)) == -1)
if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPINTVL, (const void *) &tcp_options->tcp_keepintvl, sizeof(int)) == -1)
{
TFE_STREAM_LOG_ERROR(stream, "setsockopt(TCP_KEEPINTVL, %d) failed, ignored: %s",
tcp_options->tcp_keepintvl, strerror(errno));
@@ -858,13 +858,23 @@ void __stream_fd_option_setup(struct tfe_stream_private * _stream, evutil_socket
if (tcp_options->tcp_keepidle > 0)
{
if (setsockopt(fd, SOL_SOCKET, TCP_KEEPIDLE, (const void *) &tcp_options->tcp_keepidle, sizeof(int)) == -1)
if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, (const void *) &tcp_options->tcp_keepidle, sizeof(int)) == -1)
{
TFE_STREAM_LOG_ERROR(stream, "setsockopt(TCP_KEEPIDLE, %d) failed, ignored: %s",
tcp_options->tcp_keepidle, strerror(errno));
}
}
if (tcp_options->tcp_user_timeout > 0)
{
if (setsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT, (const void *) &tcp_options->tcp_user_timeout, sizeof(int))
== -1)
{
TFE_STREAM_LOG_ERROR(stream, "setsockopt(TCP_USER_TIMEOUT, %d) failed, ignored: %s",
tcp_options->tcp_user_timeout, strerror(errno));
}
}
return;
}
@@ -932,7 +942,7 @@ int tfe_stream_option_set(struct tfe_stream * stream, enum tfe_stream_option opt
return 0;
}
void tfe_stream_write_log(const struct tfe_stream * stream, int level, const char * fmt, ...)
void tfe_stream_write_access_log(const struct tfe_stream * stream, int level, const char * fmt, ...)
{
va_list arg_ptr;
va_start(arg_ptr, fmt);