From ecb0434e8f0675f2e0702fc972de210671d12b82 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Mon, 30 Sep 2013 01:41:23 +0000 Subject: [PATCH] dbms: Client: tiny improvement [#CONV-2944]. --- dbms/src/Client/Client.cpp | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/dbms/src/Client/Client.cpp b/dbms/src/Client/Client.cpp index 3a2c82c4a69..260a166eef8 100644 --- a/dbms/src/Client/Client.cpp +++ b/dbms/src/Client/Client.cpp @@ -64,10 +64,15 @@ class InterruptListener { private: bool active; + sigset_t sig_set; public: InterruptListener() : active(false) { + if (sigemptyset(&sig_set) + || sigaddset(&sig_set, SIGINT)) + throwFromErrno("Cannot manipulate with signal set.", ErrorCodes::CANNOT_MANIPULATE_SIGSET); + block(); } @@ -82,11 +87,6 @@ public: return false; timespec timeout = { 0, 0 }; - sigset_t sig_set; - - if (sigemptyset(&sig_set) - || sigaddset(&sig_set, SIGINT)) - throwFromErrno("Cannot manipulate with signal set.", ErrorCodes::CANNOT_MANIPULATE_SIGSET); if (-1 == sigtimedwait(&sig_set, NULL, &timeout)) { @@ -103,12 +103,6 @@ public: { if (!active) { - sigset_t sig_set; - - if (sigemptyset(&sig_set) - || sigaddset(&sig_set, SIGINT)) - throwFromErrno("Cannot manipulate with signal set.", ErrorCodes::CANNOT_MANIPULATE_SIGSET); - if (pthread_sigmask(SIG_BLOCK, &sig_set, NULL)) throwFromErrno("Cannot block signal.", ErrorCodes::CANNOT_BLOCK_SIGNAL); @@ -121,12 +115,6 @@ public: { if (active) { - sigset_t sig_set; - - if (sigemptyset(&sig_set) - || sigaddset(&sig_set, SIGINT)) - throwFromErrno("Cannot manipulate with signal set.", ErrorCodes::CANNOT_MANIPULATE_SIGSET); - if (pthread_sigmask(SIG_UNBLOCK, &sig_set, NULL)) throwFromErrno("Cannot unblock signal.", ErrorCodes::CANNOT_UNBLOCK_SIGNAL);