[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 16:05:10 CST 2017
[ https://issues.asterisk.org/jira/browse/ASTERISK-26749?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=234879#comment-234879 ]
Richard Mudgett commented on ASTERISK-26749:
--------------------------------------------
It may be that your real problem is the fax data frames are being sent too fast and not allowing earlier frames to go out. That could be the real reason for the "Resource temporarily unavailable" error.
> 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