HTTP server stuck in function httpsrv_read() when receiving large data

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

HTTP server stuck in function httpsrv_read() when receiving large data

847件の閲覧回数
julie
Contributor I

I have a CW10.6 and MQX4.2 project which runs on K60F120M. I found that when large data(the size is greater than HTTPSRVCFG_RX_BUFFER_SIZE) is uploaded to the HTTP server, sometimes the server is stuck in httpsrv_read() function (in httpsrv_supp.c), the call to httpsrv_recv() returns 0 while (read<len), so the function is stuck forever while waiting for more data.

Here is the code snippet of httpsrv_read:

    /* If there is some space remaining in user buffer try to read from socket */
    while (read < len)
    {
        uint32_t received;

        received = httpsrv_recv(session, dst+read, len-read, 0);
        if ((uint32_t)RTCS_ERROR != received)
        {
            read += received;
        }
        else
        {
            break;
        }
    }

Before digging deeper into the RTCS code, I'd like to know if anybody else had the same problem? And if yes, how to solve it?

Thank you very much for your help,

Julie

ラベル(1)
タグ(1)
0 件の賞賛
2 返答(返信)

698件の閲覧回数
Martin_
NXP Employee
NXP Employee

or, actually, maybe the code needs to add a check for zero bytes return value, to return to the caller in case of the receive timeout:

/* If there is some space remaining in user buffer try to read from socket */
    while (read < len)
    {
        uint32_t received;

        received = httpsrv_recv(session, dst+read, len-read, 0);
       
if (received && ((uint32_t)RTCS_ERROR != received))
        {
            read += received;
        }
        else
        {
            break;
        }
    }

0 件の賞賛

698件の閲覧回数
Martin_
NXP Employee
NXP Employee

you might try to increase the OPT_RECEIVE_TIMEOUT session socket option. In case of timeout on the session socket (no incoming data) the recv() function returns with whatever data has been buffered, possibly zero.

HTTPSRVCFG_RECEIVE_TIMEOUT compile time macro, in milliseconds.

0 件の賞賛