[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 Feb 8 12:58:10 CST 2017


     [ https://issues.asterisk.org/jira/browse/ASTERISK-26749?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Richard Mudgett closed ASTERISK-26749.
--------------------------------------

    Resolution: Suspended

Closing because the suggested change seems like the wrong thing to do because it results in the channel hanging up.  Also this is reported against an unsupported 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()*.
> *dahdi_write()* is one of the tech interface methods and not returning -1 in case of write error informs other side (asterisk, sending application) that channel has successfully digested the frame. Thus, in my case SendFax() application believes the fax was successfully transmitted, which is not the case, since *my_dahdi_write()* silently drops data in case of failure.  



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



More information about the asterisk-bugs mailing list