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
2f71b647
Commit
2f71b647
authored
Jan 01, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sig_handlers: use event_pipe for delivering SIGHUP
The signal_check library went out of order when we started using the GLib main loop. Convert the SIGHUP handler to use event_pipe instead.
parent
e93136ef
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
12 deletions
+16
-12
event_pipe.h
src/event_pipe.h
+3
-0
sig_handlers.c
src/sig_handlers.c
+13
-10
sig_handlers.h
src/sig_handlers.h
+0
-2
No files found.
src/event_pipe.h
View file @
2f71b647
...
@@ -40,6 +40,9 @@ enum pipe_event {
...
@@ -40,6 +40,9 @@ enum pipe_event {
/** must call syncPlayerAndPlaylist() */
/** must call syncPlayerAndPlaylist() */
PIPE_EVENT_PLAYLIST
,
PIPE_EVENT_PLAYLIST
,
/** SIGHUP received: reload configuration, roll log file */
PIPE_EVENT_RELOAD
,
PIPE_EVENT_MAX
PIPE_EVENT_MAX
};
};
...
...
src/sig_handlers.c
View file @
2f71b647
...
@@ -18,10 +18,10 @@
...
@@ -18,10 +18,10 @@
*/
*/
#include "sig_handlers.h"
#include "sig_handlers.h"
#include "command.h"
#include "signal_check.h"
#include "signal_check.h"
#include "log.h"
#include "log.h"
#include "main.h"
#include "main.h"
#include "event_pipe.h"
#include <glib.h>
#include <glib.h>
...
@@ -34,6 +34,11 @@ static void exit_signal_handler(G_GNUC_UNUSED int signum)
...
@@ -34,6 +34,11 @@ static void exit_signal_handler(G_GNUC_UNUSED int signum)
g_main_loop_quit
(
main_loop
);
g_main_loop_quit
(
main_loop
);
}
}
static
void
reload_signal_handler
(
G_GNUC_UNUSED
int
signum
)
{
event_pipe_emit_fast
(
PIPE_EVENT_RELOAD
);
}
static
void
static
void
x_sigaction
(
int
signum
,
const
struct
sigaction
*
act
)
x_sigaction
(
int
signum
,
const
struct
sigaction
*
act
)
{
{
...
@@ -41,16 +46,11 @@ x_sigaction(int signum, const struct sigaction *act)
...
@@ -41,16 +46,11 @@ x_sigaction(int signum, const struct sigaction *act)
g_error
(
"sigaction() failed: %s"
,
strerror
(
errno
));
g_error
(
"sigaction() failed: %s"
,
strerror
(
errno
));
}
}
int
handlePendingSignals
(
void
)
static
void
handle_reload_event
(
void
)
{
{
if
(
signal_is_pending
(
SIGHUP
))
{
DEBUG
(
"got SIGHUP, rereading DB
\n
"
);
DEBUG
(
"got SIGHUP, rereading DB
\n
"
);
signal_clear
(
SIGHUP
);
cycle_log_files
();
if
(
cycle_log_files
()
<
0
)
return
COMMAND_RETURN_KILL
;
}
return
0
;
}
}
void
initSigHandlers
(
void
)
void
initSigHandlers
(
void
)
...
@@ -66,6 +66,9 @@ void initSigHandlers(void)
...
@@ -66,6 +66,9 @@ void initSigHandlers(void)
x_sigaction
(
SIGINT
,
&
sa
);
x_sigaction
(
SIGINT
,
&
sa
);
x_sigaction
(
SIGTERM
,
&
sa
);
x_sigaction
(
SIGTERM
,
&
sa
);
event_pipe_register
(
PIPE_EVENT_RELOAD
,
handle_reload_event
);
sa
.
sa_handler
=
reload_signal_handler
;
x_sigaction
(
SIGHUP
,
&
sa
);
signal_handle
(
SIGUSR1
);
signal_handle
(
SIGUSR1
);
signal_handle
(
SIGHUP
);
}
}
src/sig_handlers.h
View file @
2f71b647
...
@@ -19,8 +19,6 @@
...
@@ -19,8 +19,6 @@
#ifndef MPD_SIG_HANDLERS_H
#ifndef MPD_SIG_HANDLERS_H
#define MPD_SIG_HANDLERS_H
#define MPD_SIG_HANDLERS_H
int
handlePendingSignals
(
void
);
void
initSigHandlers
(
void
);
void
initSigHandlers
(
void
);
#endif
#endif
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