Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
c9da34dd
C
ClickHouse
项目概览
2dot5
/
ClickHouse
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
ClickHouse
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
c9da34dd
编写于
3月 29, 2018
作者:
A
alexey-milovidov
提交者:
GitHub
3月 29, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2139 from proller/fix16
CLICKHOUSE-3644: Server: do not use SO_REUSEPORT
上级
aeaf8cf1
037cf622
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
49 addition
and
33 deletion
+49
-33
contrib/poco
contrib/poco
+1
-1
dbms/src/Server/Server.cpp
dbms/src/Server/Server.cpp
+48
-32
未找到文件。
poco
@
a107b0c9
比较
3dae7c46
...
a107b0c9
Subproject commit
3dae7c46e813d884d15ff509f6dcc1693417646f
Subproject commit
a107b0c9cee109fe0abfbf509df3c78a1e0c05fa
dbms/src/Server/Server.cpp
浏览文件 @
c9da34dd
...
...
@@ -326,7 +326,7 @@ int Server::main(const std::vector<std::string> & /*args*/)
std
::
vector
<
std
::
string
>
listen_hosts
=
DB
::
getMultipleValuesFromConfig
(
config
(),
""
,
"listen_host"
);
bool
listen_try
=
config
().
get
UInt
(
"listen_try"
,
false
);
bool
listen_try
=
config
().
get
Bool
(
"listen_try"
,
false
);
if
(
listen_hosts
.
empty
())
{
listen_hosts
.
emplace_back
(
"::1"
);
...
...
@@ -362,6 +362,23 @@ int Server::main(const std::vector<std::string> & /*args*/)
return
socket_address
;
};
auto
socket_bind_listen
=
[
&
](
auto
&
socket
,
const
std
::
string
&
host
,
UInt16
port
,
bool
secure
=
0
)
{
auto
address
=
make_socket_address
(
host
,
port
);
#if !POCO_CLICKHOUSE_PATCH || POCO_VERSION <= 0x02000000 // TODO: fill correct version
if
(
secure
)
/// Bug in old poco, listen() after bind() with reusePort param will fail because have no implementation in SecureServerSocketImpl
/// https://github.com/pocoproject/poco/pull/2257
socket
.
bind
(
address
,
true
);
else
#endif
socket
.
bind
(
address
,
/* reuseAddress = */
true
,
/* reusePort = */
config
().
getBool
(
"listen_reuse_port"
,
false
));
socket
.
listen
(
/* backlog = */
config
().
getUInt
(
"listen_backlog"
,
64
));
return
address
;
};
for
(
const
auto
&
listen_host
:
listen_hosts
)
{
/// For testing purposes, user may omit tcp_port or http_port or https_port in configuration file.
...
...
@@ -370,18 +387,17 @@ int Server::main(const std::vector<std::string> & /*args*/)
/// HTTP
if
(
config
().
has
(
"http_port"
))
{
Poco
::
Net
::
SocketAddress
http_socket_address
=
make_socket_address
(
listen_host
,
config
().
getInt
(
"http_port"
));
Poco
::
Net
::
ServerSocket
http_socket
(
http_socket_address
);
http_socket
.
setReceiveTimeout
(
settings
.
http_receive_timeout
);
http_socket
.
setSendTimeout
(
settings
.
http_send_timeout
);
Poco
::
Net
::
ServerSocket
socket
;
auto
address
=
socket_bind_listen
(
socket
,
listen_host
,
config
().
getInt
(
"http_port"
));
socket
.
setReceiveTimeout
(
settings
.
http_receive_timeout
);
socket
.
setSendTimeout
(
settings
.
http_send_timeout
);
servers
.
emplace_back
(
new
Poco
::
Net
::
HTTPServer
(
new
HTTPHandlerFactory
(
*
this
,
"HTTPHandler-factory"
),
server_pool
,
http_
socket
,
socket
,
http_params
));
LOG_INFO
(
log
,
"Listening http://"
+
http_socket_
address
.
toString
());
LOG_INFO
(
log
,
"Listening http://"
+
address
.
toString
());
}
/// HTTPS
...
...
@@ -389,18 +405,18 @@ int Server::main(const std::vector<std::string> & /*args*/)
{
#if Poco_NetSSL_FOUND
std
::
call_once
(
ssl_init_once
,
SSLInit
);
Poco
::
Net
::
SocketAddress
http_socket_address
=
make_socket_address
(
listen_host
,
config
().
getInt
(
"https_port"
));
Poco
::
Net
::
SecureServerSocket
http_socket
(
http_socket_address
);
http_socket
.
setReceiveTimeout
(
settings
.
http_receive_timeout
);
http_socket
.
setSendTimeout
(
settings
.
http_send_timeout
);
Poco
::
Net
::
SecureServerSocket
socket
;
auto
address
=
socket_bind_listen
(
socket
,
listen_host
,
config
().
getInt
(
"https_port"
),
/* secure = */
true
);
socket
.
setReceiveTimeout
(
settings
.
http_receive_timeout
);
socket
.
setSendTimeout
(
settings
.
http_send_timeout
);
servers
.
emplace_back
(
new
Poco
::
Net
::
HTTPServer
(
new
HTTPHandlerFactory
(
*
this
,
"HTTPSHandler-factory"
),
server_pool
,
http_
socket
,
socket
,
http_params
));
LOG_INFO
(
log
,
"Listening https://"
+
http_socket_
address
.
toString
());
LOG_INFO
(
log
,
"Listening https://"
+
address
.
toString
());
#else
throw
Exception
{
"HTTPS protocol is disabled because Poco library was built without NetSSL support."
,
ErrorCodes
::
SUPPORT_IS_DISABLED
};
...
...
@@ -411,33 +427,33 @@ int Server::main(const std::vector<std::string> & /*args*/)
if
(
config
().
has
(
"tcp_port"
))
{
std
::
call_once
(
ssl_init_once
,
SSLInit
);
Poco
::
Net
::
S
ocketAddress
tcp_address
=
make_socket_address
(
listen_host
,
config
().
getInt
(
"tcp_port"
))
;
Poco
::
Net
::
ServerSocket
tcp_socket
(
tcp_address
);
tcp_
socket
.
setReceiveTimeout
(
settings
.
receive_timeout
);
tcp_
socket
.
setSendTimeout
(
settings
.
send_timeout
);
Poco
::
Net
::
S
erverSocket
socket
;
auto
address
=
socket_bind_listen
(
socket
,
listen_host
,
config
().
getInt
(
"tcp_port"
)
);
socket
.
setReceiveTimeout
(
settings
.
receive_timeout
);
socket
.
setSendTimeout
(
settings
.
send_timeout
);
servers
.
emplace_back
(
new
Poco
::
Net
::
TCPServer
(
new
TCPHandlerFactory
(
*
this
),
server_pool
,
tcp_
socket
,
socket
,
new
Poco
::
Net
::
TCPServerParams
));
LOG_INFO
(
log
,
"Listening tcp: "
+
tcp_
address
.
toString
());
LOG_INFO
(
log
,
"Listening tcp: "
+
address
.
toString
());
}
/// TCP with SSL
if
(
config
().
has
(
"tcp_port_secure"
))
{
#if Poco_NetSSL_FOUND
Poco
::
Net
::
S
ocketAddress
tcp_address
=
make_socket_address
(
listen_host
,
config
().
getInt
(
"tcp_port_secure"
))
;
Poco
::
Net
::
SecureServerSocket
tcp_socket
(
tcp_address
);
tcp_
socket
.
setReceiveTimeout
(
settings
.
receive_timeout
);
tcp_
socket
.
setSendTimeout
(
settings
.
send_timeout
);
Poco
::
Net
::
S
ecureServerSocket
socket
;
auto
address
=
socket_bind_listen
(
socket
,
listen_host
,
config
().
getInt
(
"tcp_port_secure"
),
/* secure = */
true
);
socket
.
setReceiveTimeout
(
settings
.
receive_timeout
);
socket
.
setSendTimeout
(
settings
.
send_timeout
);
servers
.
emplace_back
(
new
Poco
::
Net
::
TCPServer
(
new
TCPHandlerFactory
(
*
this
,
/* secure= */
true
),
server_pool
,
tcp_
socket
,
socket
,
new
Poco
::
Net
::
TCPServerParams
));
LOG_INFO
(
log
,
"Listening tcp_secure: "
+
tcp_
address
.
toString
());
LOG_INFO
(
log
,
"Listening tcp_secure: "
+
address
.
toString
());
#else
throw
Exception
{
"SSL support for TCP protocol is disabled because Poco library was built without NetSSL support."
,
ErrorCodes
::
SUPPORT_IS_DISABLED
};
...
...
@@ -451,17 +467,17 @@ int Server::main(const std::vector<std::string> & /*args*/)
/// Interserver IO HTTP
if
(
config
().
has
(
"interserver_http_port"
))
{
Poco
::
Net
::
S
ocketAddress
interserver_address
=
make_socket_address
(
listen_host
,
config
().
getInt
(
"interserver_http_port"
))
;
Poco
::
Net
::
ServerSocket
interserver_io_http_socket
(
interserver_address
);
interserver_io_http_
socket
.
setReceiveTimeout
(
settings
.
http_receive_timeout
);
interserver_io_http_
socket
.
setSendTimeout
(
settings
.
http_send_timeout
);
Poco
::
Net
::
S
erverSocket
socket
;
auto
address
=
socket_bind_listen
(
socket
,
listen_host
,
config
().
getInt
(
"interserver_http_port"
)
);
socket
.
setReceiveTimeout
(
settings
.
http_receive_timeout
);
socket
.
setSendTimeout
(
settings
.
http_send_timeout
);
servers
.
emplace_back
(
new
Poco
::
Net
::
HTTPServer
(
new
InterserverIOHTTPHandlerFactory
(
*
this
,
"InterserverIOHTTPHandler-factory"
),
server_pool
,
interserver_io_http_
socket
,
socket
,
http_params
));
LOG_INFO
(
log
,
"Listening interserver
: "
+
interserver_
address
.
toString
());
LOG_INFO
(
log
,
"Listening interserver
http: "
+
address
.
toString
());
}
}
catch
(
const
Poco
::
Net
::
NetException
&
e
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录