Skip to content

Commit

Permalink
gearman_wait gearman#230 don't ignore signal by flag
Browse files Browse the repository at this point in the history
  • Loading branch information
borro committed Mar 22, 2019
1 parent 64716ae commit 8758fe4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
14 changes: 13 additions & 1 deletion libgearman/interface/universal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

/**
Expand All @@ -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}
{ }
Expand Down Expand Up @@ -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)
Expand Down
13 changes: 13 additions & 0 deletions libgearman/universal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 8758fe4

Please sign in to comment.