[asterisk-bugs] [JIRA] Commented: (ASTERISK-20061) PHP Agi Socket Server stopped working - socket_read spamming Resource temporarily unavailable
Jonathan Rose (JIRA)
noreply at issues.asterisk.org
Wed Jul 25 15:31:21 CDT 2012
[ https://issues.asterisk.org/jira/browse/ASTERISK-20061?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=195210#comment-195210 ]
Jonathan Rose commented on ASTERISK-20061:
------------------------------------------
Hey Eike, I'm not 100% positive on this, but it looks to me like you probably didn't send a newline character at the end of your AGI message to Asterisk.
I say this because:
from: AGI Rx << temp buffer SET VARIABLE VMACTIVE_FIRST ""
SET VARIABLE VMACTIVE_FIRST "" - looks like a complete AGI command, so if the errno becomes EGAIN here (which is what correlates with that Resource temporarily unavailable message), that means we are anticipating more stuff to enter that buffer, which means we haven't received either an EOF or a newline yet.
I think I'll go ahead and add a little note to the end of that to this message indicating that it still anticipates a newline, but if you could get back to me with either your server script or a confirmation that this is what's happening or that you know for sure this isn't what is happening, that would be very helpful.
> PHP Agi Socket Server stopped working - socket_read spamming Resource temporarily unavailable
> ---------------------------------------------------------------------------------------------
>
> Key: ASTERISK-20061
> URL: https://issues.asterisk.org/jira/browse/ASTERISK-20061
> Project: Asterisk
> Issue Type: Bug
> Security Level: None
> Components: Resources/res_agi
> Affects Versions: 1.8.13.0
> Environment: CentOS 5, kernel-2.6.238
> Reporter: Eike Kuiper
> Assignee: Matt Jordan
> Severity: Minor
> Attachments: debug.log
>
>
> Hi Developers,
> I have a php agi socket server and various classes to extend my pbx. This socket server worked well with Ver. 1.8.6.0,
> but after i updated to version 1.8.13.0 it stopped working. The function socket_read threw the error 11(Ressource temporarily unavailable). I searched the mistake in the res_agi.c file and found that the following lines caused an infinite loop:
> {noformat}
> while (len > 1) {
> res = fgets(buf + buflen, len, readf);
> if (feof(readf))
> break;
> if (ferror(readf) && ((errno != EINTR) && (errno != EAGAIN)))
> break;
> if (res != NULL && !agi->fast)
> break;
> buflen = strlen(buf);
> if (buflen && buf[buflen - 1] == '\n')
> break;
> len = sizeof(buf) - buflen;
> if (agidebug)
> ast_verbose( "AGI Rx << temp buffer %s - errno %s\n", buf, strerror(errno));
> }
> {noformat}
> Comparing the res_agi.c file from Ver. 1.8.13.0 and 1.8.6.0, i changed the following back to Ver. 1.8.6.0:
> while (len > 1) {
> to:
> while (buflen < (len - 1)) {
> and:
> len = sizeof(buf) - buflen;
> to:
> len -= buflen;
> After i compiled these changes (fully recompiled asterisk in fact) and updated my pbx again and
> my php agi socket server were fully working.
> I don't understand correctly why the len is set to the size of the bytes for this datatype and substracting the lenght of buf string.
> Cheers
> Eike
> P.S: Please excuse my bad english...
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the asterisk-bugs
mailing list