mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
dbms: Client: tiny improvement [#CONV-2944].
This commit is contained in:
parent
0629fb4fdd
commit
ecb0434e8f
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user