Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
43863a70
Commit
43863a70
authored
Oct 18, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SignalMonitor: add SignalMonitorGetEventLoop()
Eliminate the global variable "shutdown_loop".
parent
bd5a70c7
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
6 deletions
+16
-6
SignalHandlers.cxx
src/SignalHandlers.cxx
+1
-6
SignalMonitor.cxx
src/event/SignalMonitor.cxx
+8
-0
SignalMonitor.hxx
src/event/SignalMonitor.hxx
+7
-0
No files found.
src/SignalHandlers.cxx
View file @
43863a70
...
@@ -25,9 +25,7 @@
...
@@ -25,9 +25,7 @@
#include "Log.hxx"
#include "Log.hxx"
#include "LogInit.hxx"
#include "LogInit.hxx"
#include "Main.hxx"
#include "event/Loop.hxx"
#include "event/Loop.hxx"
#include "GlobalEvents.hxx"
#include "system/FatalError.hxx"
#include "system/FatalError.hxx"
#include "util/Domain.hxx"
#include "util/Domain.hxx"
...
@@ -35,12 +33,10 @@
...
@@ -35,12 +33,10 @@
static
constexpr
Domain
signal_handlers_domain
(
"signal_handlers"
);
static
constexpr
Domain
signal_handlers_domain
(
"signal_handlers"
);
static
EventLoop
*
shutdown_loop
;
static
void
static
void
HandleShutdownSignal
()
HandleShutdownSignal
()
{
{
shutdown_loop
->
Break
();
SignalMonitorGetEventLoop
().
Break
();
}
}
static
void
static
void
...
@@ -72,7 +68,6 @@ SignalHandlersInit(EventLoop &loop)
...
@@ -72,7 +68,6 @@ SignalHandlersInit(EventLoop &loop)
sa
.
sa_handler
=
SIG_IGN
;
sa
.
sa_handler
=
SIG_IGN
;
x_sigaction
(
SIGPIPE
,
&
sa
);
x_sigaction
(
SIGPIPE
,
&
sa
);
shutdown_loop
=
&
loop
;
SignalMonitorRegister
(
SIGINT
,
HandleShutdownSignal
);
SignalMonitorRegister
(
SIGINT
,
HandleShutdownSignal
);
SignalMonitorRegister
(
SIGTERM
,
HandleShutdownSignal
);
SignalMonitorRegister
(
SIGTERM
,
HandleShutdownSignal
);
...
...
src/event/SignalMonitor.cxx
View file @
43863a70
...
@@ -63,6 +63,8 @@ public:
...
@@ -63,6 +63,8 @@ public:
SocketMonitor
::
Steal
();
SocketMonitor
::
Steal
();
}
}
using
SocketMonitor
::
GetEventLoop
;
#ifdef USE_SIGNALFD
#ifdef USE_SIGNALFD
void
Update
(
sigset_t
&
mask
)
{
void
Update
(
sigset_t
&
mask
)
{
const
bool
was_open
=
SocketMonitor
::
IsDefined
();
const
bool
was_open
=
SocketMonitor
::
IsDefined
();
...
@@ -153,6 +155,12 @@ SignalMonitorFinish()
...
@@ -153,6 +155,12 @@ SignalMonitorFinish()
monitor
.
Destruct
();
monitor
.
Destruct
();
}
}
EventLoop
&
SignalMonitorGetEventLoop
()
{
return
monitor
->
GetEventLoop
();
}
void
void
SignalMonitorRegister
(
int
signo
,
SignalHandler
handler
)
SignalMonitorRegister
(
int
signo
,
SignalHandler
handler
)
{
{
...
...
src/event/SignalMonitor.hxx
View file @
43863a70
...
@@ -41,6 +41,13 @@ void
...
@@ -41,6 +41,13 @@ void
SignalMonitorFinish
();
SignalMonitorFinish
();
/**
/**
* Obtain a reference to the #EventLoop that was passed to
* SignalMonitorInit().
*/
EventLoop
&
SignalMonitorGetEventLoop
();
/**
* Register a handler for the specified signal. The handler will be
* Register a handler for the specified signal. The handler will be
* invoked in a safe context.
* invoked in a safe context.
*/
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment