From 726428a2c5e42e426720dde8a695fa829670b4e4 Mon Sep 17 00:00:00 2001 From: alesapin Date: Tue, 21 Aug 2018 18:24:20 +0300 Subject: [PATCH] Add timeout to socket --- dbms/src/Common/TaskStatsInfoGetter.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dbms/src/Common/TaskStatsInfoGetter.cpp b/dbms/src/Common/TaskStatsInfoGetter.cpp index 8f4d1c6c4ee..a9e5f6f636a 100644 --- a/dbms/src/Common/TaskStatsInfoGetter.cpp +++ b/dbms/src/Common/TaskStatsInfoGetter.cpp @@ -139,7 +139,13 @@ void TaskStatsInfoGetter::init() if (netlink_socket_fd >= 0) return; + struct timeval tv; + tv.tv_sec = 5; + tv.tv_usec = 0; + netlink_socket_fd = ::socket(PF_NETLINK, SOCK_RAW, NETLINK_GENERIC); + ::setsockopt(netlink_socket_fd, SOL_SOCKET, SO_RCVTIMEO, reinterpret_cast(&tv), sizeof(tv)); + if (netlink_socket_fd < 0) throwFromErrno("Can't create PF_NETLINK socket");