[asterisk-commits] Channel alert pipe: improve diagnostic error return (asterisk[11])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jul 2 06:24:48 CDT 2015


Joshua Colp has submitted this change and it was merged.

Change subject: Channel alert pipe: improve diagnostic error return
......................................................................


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
---
M main/channel_internal_api.c
1 file changed, 10 insertions(+), 1 deletion(-)

Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve
  Richard Mudgett: Looks good to me, but someone else must approve
  Anonymous Coward #1000019: Verified
  Matt Jordan: Looks good to me, approved



diff --git a/main/channel_internal_api.c b/main/channel_internal_api.c
index 3cfa681..30790d0 100644
--- a/main/channel_internal_api.c
+++ b/main/channel_internal_api.c
@@ -1098,7 +1098,14 @@
 int ast_channel_alert_write(struct ast_channel *chan)
 {
 	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)
@@ -1149,9 +1156,11 @@
 {
 	if (ast_channel_internal_alert_readable(chan)) {
 		close(chan->alertpipe[0]);
+		chan->alertpipe[0] = -1;
 	}
 	if (ast_channel_alert_writable(chan)) {
 		close(chan->alertpipe[1]);
+		chan->alertpipe[1] = -1;
 	}
 }
 

-- 
To view, visit https://gerrit.asterisk.org/755
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I1bf7b3337ad392789a9f02c650589cd065d20b5b
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 11
Gerrit-Owner: Scott Griepentrog <sgriepentrog at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>



More information about the asterisk-commits mailing list