Open a file in cgi call back function cause overflow?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Open a file in cgi call back function cause overflow?

Jump to solution
874 Views
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 Kudos
1 Solution
595 Views
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

View solution in original post

0 Kudos
6 Replies
596 Views
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 Kudos
595 Views
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 Kudos
595 Views
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 Kudos
595 Views
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 Kudos
595 Views
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

595 Views
danielchai
Senior Contributor I

Hi Garabo,

Thank you.

-Daniel

0 Kudos