Skip to content
Snippets Groups Projects
Commit 6b16fbfc authored by Scott Griepentrog's avatar Scott Griepentrog Committed by Scott Griepentrog
Browse files

Channel alert pipe: improve diagnostic error return

When a frame is queued on a channel, any failure in
ast_channel_alert_write is logged along with errno.

This change improves the diagnostic message through
aligning the errno value with actual failure cases.

ASTERISK-25224
Reported by: Andrey Biglari

Change-Id: I1bf7b3337ad392789a9f02c650589cd065d20b5b
parent 69bfa518
No related branches found
No related tags found
No related merge requests found
...@@ -1210,7 +1210,14 @@ void ast_channel_named_pickupgroups_set(struct ast_channel *chan, struct ast_nam ...@@ -1210,7 +1210,14 @@ void ast_channel_named_pickupgroups_set(struct ast_channel *chan, struct ast_nam
int ast_channel_alert_write(struct ast_channel *chan) int ast_channel_alert_write(struct ast_channel *chan)
{ {
char blah = 0x7F; char blah = 0x7F;
return ast_channel_alert_writable(chan) && write(chan->alertpipe[1], &blah, sizeof(blah)) != sizeof(blah);
if (!ast_channel_alert_writable(chan)) {
errno = EBADF;
return 0;
}
/* preset errno in case returned size does not match */
errno = EPIPE;
return write(chan->alertpipe[1], &blah, sizeof(blah)) != sizeof(blah);
} }
ast_alert_status_t ast_channel_internal_alert_read(struct ast_channel *chan) ast_alert_status_t ast_channel_internal_alert_read(struct ast_channel *chan)
...@@ -1261,9 +1268,11 @@ void ast_channel_internal_alertpipe_close(struct ast_channel *chan) ...@@ -1261,9 +1268,11 @@ void ast_channel_internal_alertpipe_close(struct ast_channel *chan)
{ {
if (ast_channel_internal_alert_readable(chan)) { if (ast_channel_internal_alert_readable(chan)) {
close(chan->alertpipe[0]); close(chan->alertpipe[0]);
chan->alertpipe[0] = -1;
} }
if (ast_channel_alert_writable(chan)) { if (ast_channel_alert_writable(chan)) {
close(chan->alertpipe[1]); close(chan->alertpipe[1]);
chan->alertpipe[1] = -1;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment