[asterisk-bugs] [JIRA] (ASTERISK-26749) chan_dahdi.c: my_dahdi_write() returns zero even if it fails.

Richard Mudgett (JIRA) noreply at issues.asterisk.org
Wed Jan 25 15:51:10 CST 2017


    [ https://issues.asterisk.org/jira/browse/ASTERISK-26749?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=234877#comment-234877 ] 

Richard Mudgett commented on ASTERISK-26749:
--------------------------------------------

That patch is ready for review on gerrit.  It does exactly what you are saying.  I put it here for you to test to see if it is really what you need.  Though, if anything further is needed you'll really need to move to a supported Asterisk version.

> chan_dahdi.c: my_dahdi_write() returns zero even if it fails. 
> --------------------------------------------------------------
>
>                 Key: ASTERISK-26749
>                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-26749
>             Project: Asterisk
>          Issue Type: Bug
>      Security Level: None
>          Components: Channels/chan_dahdi
>         Environment: Gentoo Linux, asterisk 1.8.31.1
>            Reporter: Segii Cherkavskyi
>            Assignee: Richard Mudgett
>         Attachments: asterisk-15-12-2017-10-02-55.log, jira_asterisk_26749_v13.patch
>
>
> Although my asterisk version is not the newest, I checked chan_dahdi.c in the more recent asterisk version (13) and the code in question is remained untouched, so here is the problem: 
> {code:title=chan_dahdi.c|borderStyle=solid}
> static int my_dahdi_write(struct dahdi_pvt *p, unsigned char *buf, int len, int idx, int linear)
> {
> 	int sent=0;
> 	int size;
> 	int res;
> 	int fd;
> 	fd = p->subs[idx].dfd;
> 	while (len) {
> 		size = len;
> 		if (size > (linear ? READ_SIZE * 2 : READ_SIZE))
> 			size = (linear ? READ_SIZE * 2 : READ_SIZE);
> 		res = write(fd, buf, size);
> 		if (res != size) {
> 			ast_debug(1, "Write returned %d (%s) on channel %d\n", res, strerror(errno), p->channel);
> 			return sent;
> 		}
> 		len -= size;
> 		buf += size;
> 	}
> 	return sent;
> }
> {code}
> *apps/chan_dahdi.c* has a method *my_dahdi_write()*, which returns *0*, even if writing to a file descriptor fails. In case of failure *my_dahdi_write()* produces the following log output:
> {noformat}
> chan_dahdi.c: Write returned -1 (Resource temporarily unavailable) on channel 4
> {noformat}
> The return value of the method *my_dahdi_write()* is checked by the calling function *dahdi_write()* and returns with *-1*, in case if *my_dahdi_write()* fails, {color:red}which never happens{color}. 
> While searching through the asterisk issue tracker, I found similar logs to the one I have, with discussions about echo cancellation etc. not directly discussing the return value of *my_dahdi_write()*.



--
This message was sent by Atlassian JIRA
(v6.2#6252)



More information about the asterisk-bugs mailing list