[asterisk-commits] file: trunk r373553 - in /trunk: ./ res/res_rtp_multicast.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Sep 25 07:12:23 CDT 2012


Author: file
Date: Tue Sep 25 07:12:20 2012
New Revision: 373553

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=373553
Log:
Fix an issue where a caller to ast_write on a MulticastRTP channel would determine it failed when in reality it did not.

When sending RTP packets via multicast the amount of data sent is stored in a variable and returned
from the write function. This is incorrect as any non-zero value returned is considered a failure while
a return value of 0 is success. For callers (such as ast_streamfile) that checked the return value
they would have considered it a failure when in reality nothing went wrong and it was actually a success.

The write function for the multicast RTP engine now returns -1 on failure and 0 on success, as it should.

(closes issue ASTERISK-17254)
Reported by: wybecom
........

Merged revisions 373550 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 373551 from http://svn.asterisk.org/svn/asterisk/branches/10
........

Merged revisions 373552 from http://svn.asterisk.org/svn/asterisk/branches/11

Modified:
    trunk/   (props changed)
    trunk/res/res_rtp_multicast.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-11-merged' - no diff available.

Modified: trunk/res/res_rtp_multicast.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_rtp_multicast.c?view=diff&rev=373553&r1=373552&r2=373553
==============================================================================
--- trunk/res/res_rtp_multicast.c (original)
+++ trunk/res/res_rtp_multicast.c Tue Sep 25 07:12:20 2012
@@ -208,7 +208,7 @@
 	struct multicast_rtp *multicast = ast_rtp_instance_get_data(instance);
 	struct ast_frame *f = frame;
 	struct ast_sockaddr remote_address;
-	int hdrlen = 12, res, codec;
+	int hdrlen = 12, res = 0, codec;
 	unsigned char *rtpheader;
 
 	/* We only accept audio, nothing else */
@@ -237,12 +237,12 @@
 
 	/* Finally send it out to the eager phones listening for us */
 	ast_rtp_instance_get_remote_address(instance, &remote_address);
-	res = ast_sendto(multicast->socket, (void *) rtpheader, f->datalen + hdrlen, 0, &remote_address);
-
-	if (res < 0) {
+
+	if (ast_sendto(multicast->socket, (void *) rtpheader, f->datalen + hdrlen, 0, &remote_address) < 0) {
 		ast_log(LOG_ERROR, "Multicast RTP Transmission error to %s: %s\n",
 			ast_sockaddr_stringify(&remote_address),
 			strerror(errno));
+		res = -1;
 	}
 
 	/* If we were forced to duplicate the frame free the new one */




More information about the asterisk-commits mailing list