Open a file in cgi call back function cause overflow?

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

Open a file in cgi call back function cause overflow?

ソリューションへジャンプ
2,033件の閲覧回数
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,754件の閲覧回数
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,755件の閲覧回数
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,754件の閲覧回数
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,754件の閲覧回数
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,754件の閲覧回数
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,754件の閲覧回数
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,754件の閲覧回数
danielchai
Senior Contributor I

Hi Garabo,

Thank you.

-Daniel

0 件の賞賛
返信