From 8758fe43acc8e783b7bb3ec4b55b2158b50a96bb Mon Sep 17 00:00:00 2001 From: Boris Tavadov Date: Fri, 22 Mar 2019 12:36:52 +0300 Subject: [PATCH] gearman_wait #230 don't ignore signal by flag --- libgearman/interface/universal.hpp | 14 +++++++++++++- libgearman/universal.cc | 13 +++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/libgearman/interface/universal.hpp b/libgearman/interface/universal.hpp index 1575db5be..20e086367 100644 --- a/libgearman/interface/universal.hpp +++ b/libgearman/interface/universal.hpp @@ -51,7 +51,8 @@ enum universal_options_t GEARMAN_UNIVERSAL_NON_BLOCKING, GEARMAN_UNIVERSAL_DONT_TRACK_PACKETS, GEARMAN_UNIVERSAL_IDENTIFY, - GEARMAN_UNIVERSAL_MAX + GEARMAN_UNIVERSAL_MAX, + GEARMAN_UNIVERSAL_STOP_WAIT_ON_SIGNAL }; /** @@ -66,12 +67,14 @@ struct gearman_universal_st : public error_st struct Options { bool dont_track_packets; bool non_blocking; + bool stop_wait_on_signal; bool no_new_data; bool _ssl; Options() : dont_track_packets{false}, non_blocking{false}, + stop_wait_on_signal{false}, no_new_data{false}, _ssl{false} { } @@ -125,6 +128,15 @@ struct gearman_universal_st : public error_st options.non_blocking= arg_; } + bool is_stop_wait_on_signal() const + { + return options.stop_wait_on_signal; + } + void stop_wait_on_signal(bool arg_) + { + options.stop_wait_on_signal = arg_; + } + const char *error() const { if (_error.error() == nullptr) diff --git a/libgearman/universal.cc b/libgearman/universal.cc index 3426d9d06..4bd627c94 100644 --- a/libgearman/universal.cc +++ b/libgearman/universal.cc @@ -97,6 +97,7 @@ void gearman_universal_clone(gearman_universal_st &destination, const gearman_un destination.wakeup(source.has_wakeup()); (void)gearman_universal_set_option(destination, GEARMAN_UNIVERSAL_NON_BLOCKING, source.options.non_blocking); + (void)gearman_universal_set_option(destination, GEARMAN_UNIVERSAL_STOP_WAIT_ON_SIGNAL, source.options.stop_wait_on_signal); destination.ssl(source.ssl()); @@ -146,6 +147,10 @@ gearman_return_t gearman_universal_set_option(gearman_universal_st &self, univer self.options.non_blocking= value; break; + case GEARMAN_UNIVERSAL_STOP_WAIT_ON_SIGNAL: + self.options.stop_wait_on_signal= value; + break; + case GEARMAN_UNIVERSAL_DONT_TRACK_PACKETS: break; @@ -319,6 +324,10 @@ gearman_return_t gearman_wait(gearman_universal_st& universal) switch(errno) { case EINTR: + if (universal.is_stop_wait_on_signal()) + { + return GEARMAN_IO_WAIT; + } continue; case EINVAL: @@ -449,6 +458,10 @@ gearman_return_t gearman_universal_st::option(const universal_options_t& option_ non_blocking(value); break; + case GEARMAN_UNIVERSAL_STOP_WAIT_ON_SIGNAL: + stop_wait_on_signal(value); + break; + case GEARMAN_UNIVERSAL_DONT_TRACK_PACKETS: break;