[asterisk-bugs] [JIRA] Feedback Requested: (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 16:26:21 CDT 2012


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

Jonathan Rose updated ASTERISK-20061:
-------------------------------------

    Assignee: Eike Kuiper  (was: Matt Jordan)
      Status: Waiting for Feedback  (was: Open)

> 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: Eike Kuiper
>            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