[Asterisk-code-review] core: Use ast alertpipe for Asterisk signal monitoring thread. (asterisk[master])
Corey Farrell
asteriskteam at digium.com
Thu Nov 9 19:53:16 CST 2017
Corey Farrell has uploaded this change for review. ( https://gerrit.asterisk.org/7169
Change subject: core: Use ast_alertpipe for Asterisk signal monitoring thread.
......................................................................
core: Use ast_alertpipe for Asterisk signal monitoring thread.
Reduce the signal monitoring thread file descriptor use from two to one
on systems that support eventfd.
Change-Id: Id4041a237d481ff699639e153ea6982fee14a462
---
M main/asterisk.c
1 file changed, 9 insertions(+), 16 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/69/7169/1
diff --git a/main/asterisk.c b/main/asterisk.c
index d555949..bc1990d 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -1761,13 +1761,13 @@
static void _hup_handler(int num)
{
- int a = 0, save_errno = errno;
+ int save_errno = errno;
printf("Received HUP signal -- Reloading configs\n");
if (restartnow)
execvp(_argv[0], _argv);
sig_flags.need_reload = 1;
- if (sig_alert_pipe[1] != -1) {
- if (write(sig_alert_pipe[1], &a, sizeof(a)) < 0) {
+ if (ast_alertpipe_writable(sig_alert_pipe)) {
+ if (ast_alertpipe_write(sig_alert_pipe)) {
fprintf(stderr, "hup_handler: write() failed: %s\n", strerror(errno));
}
}
@@ -2169,10 +2169,7 @@
close(ast_consock);
if (!ast_opt_remote)
unlink(ast_config_AST_PID);
- if (sig_alert_pipe[0])
- close(sig_alert_pipe[0]);
- if (sig_alert_pipe[1])
- close(sig_alert_pipe[1]);
+ ast_alertpipe_close(sig_alert_pipe);
printf("%s", term_quit());
if (restart) {
int i;
@@ -2208,10 +2205,9 @@
static void __quit_handler(int num)
{
- int a = 0;
sig_flags.need_quit = 1;
- if (sig_alert_pipe[1] != -1) {
- if (write(sig_alert_pipe[1], &a, sizeof(a)) < 0) {
+ if (ast_alertpipe_writable(sig_alert_pipe)) {
+ if (ast_alertpipe_write(sig_alert_pipe)) {
fprintf(stderr, "quit_handler: write() failed: %s\n", strerror(errno));
}
}
@@ -3887,7 +3883,7 @@
{
for (;;) {
struct pollfd p = { sig_alert_pipe[0], POLLIN, 0 };
- int a;
+
ast_poll(&p, 1, -1);
if (sig_flags.need_reload) {
sig_flags.need_reload = 0;
@@ -3902,8 +3898,7 @@
quit_handler(0, SHUTDOWN_NORMAL, 0);
}
}
- if (read(sig_alert_pipe[0], &a, sizeof(a)) != sizeof(a)) {
- }
+ ast_alertpipe_read(sig_alert_pipe);
}
return NULL;
@@ -4710,9 +4705,7 @@
consolethread = pthread_self();
}
- if (pipe(sig_alert_pipe)) {
- sig_alert_pipe[0] = sig_alert_pipe[1] = -1;
- }
+ ast_alertpipe_init(sig_alert_pipe);
ast_process_pending_reloads();
--
To view, visit https://gerrit.asterisk.org/7169
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id4041a237d481ff699639e153ea6982fee14a462
Gerrit-Change-Number: 7169
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171109/a6bb8ec1/attachment.html>
More information about the asterisk-code-review
mailing list