Open a file in cgi call back function cause overflow?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Open a file in cgi call back function cause overflow?

跳至解决方案
2,035 次查看
danielchai
Senior Contributor I

Hi All,

Based on httpsrv project, I am try to create my own cgi function.

But when I try to open a file in this cgi function, it cause

"httpsrv callback handler overflow."

Any ideas about this? I am use MQX4.0.2 and TWR-K60F120M.

Thank you.

0 项奖励
回复
1 解答
1,756 次查看
Luis_Garabo
NXP TechSupport
NXP TechSupport

Hi Daniel,

perhaps you don't have enough stack. When you call the function HTTPSRV_init() you give as parameter the structure HTTPSRV_PARAM_STRUCT. In this structure you have the "script_stack" variable. This variable is the size of a stack of the script handler task in bytes. Try to set the value of this variable according to the memory requirements of your CGI callbacks. The default value is 750 bytes.

Hope this helps.

Regards,

Garabo

在原帖中查看解决方案

0 项奖励
回复
6 回复数
1,757 次查看
Luis_Garabo
NXP TechSupport
NXP TechSupport

Hi Daniel,

perhaps you don't have enough stack. When you call the function HTTPSRV_init() you give as parameter the structure HTTPSRV_PARAM_STRUCT. In this structure you have the "script_stack" variable. This variable is the size of a stack of the script handler task in bytes. Try to set the value of this variable according to the memory requirements of your CGI callbacks. The default value is 750 bytes.

Hope this helps.

Regards,

Garabo

0 项奖励
回复
1,756 次查看
danielchai
Senior Contributor I

Hi Garabo,

Thank you. It solves the problem.

The question is that when I set script_stack, this is the stack size for each cgi call back function, is it correct?

Thanks.

-Daniel

0 项奖励
回复
1,756 次查看
Luis_Garabo
NXP TechSupport
NXP TechSupport

Hi Daniel,

No, this is for the http server. That means it should be for all the CGI calls. The stack is taken from here for each one of them.

Regards,

Garabo

0 项奖励
回复
1,756 次查看
danielchai
Senior Contributor I

Hi Garabo,

Thank you.

Then if I want to add more CGI calls, I need keep extending this stack size, otherwise it will cause stack overflow, is it right?

If it is the case, is there a better way to set this stack dynamically?

Thank you.

-Daniel

0 项奖励
回复
1,756 次查看
Luis_Garabo
NXP TechSupport
NXP TechSupport

Hi Daniel,

Well, the memory is finite. So, you shall use the Task Aware Debugging to see how much memory is left in the HTTP server stack. This is not a dynamic memory allocation so you need to calculate well and assign what you think it is going to be enough. A try and test method could work. It is not the best approach but at least will give a good result.

Regards,

Garabo

1,756 次查看
danielchai
Senior Contributor I

Hi Garabo,

Thank you.

-Daniel

0 项奖励
回复