[En-Nut-Discussion] HTTP QueryString parser

Lars Andersson laran at ikp.liu.se
Fri Sep 12 09:59:39 CEST 2003


Mikael,

I use the same compiler version as you. The query string is also less than 256 chars.

I tried to implement similar code to what I explained earlier into the httpd example that comes with the NUT/OS distribution. At first it seemed to work fine, but after a while I noticed that the system was very unstable. It seems that the connection is never closed.

Could there be some memory leak?

/Lars A Andersson


-----Original Message-----
From: Mikael Adolfsson [mailto:ethernut at ma.stendahls.net]
Sent: den 10 september 2003 23:19
To: en-nut-discussion at egnite.de
Subject: RE: [En-Nut-Discussion] HTTP QueryString parser


Hi,

hmm, interesting. Since you get the right number of parameters, it sounds 
like there isn't enough memory left on the stack. Also, if there aren't 
enough memory on the heap, the parser will stop, and 
NutHttpGetParameterCount will allways return 0.

I'm not sure how much memory is required on the stack, but at least it 
uses very little memory on the heap. Try allocating more stack.

When the query string is parsed, the req->req_query property is
overwritten with the parsed data, since the decoded content is allways
less or equal the size of req_query (and I guess most users don't need the
req_query after that). The only extra allocated memory in the heap are two
times the number of parameters in the query string.

I just noted also that I'm using register hints on the local variables. 
Maybe there's a compiler issue here. What compiler/version do you use? 
I'm using avr-gcc 3.3(20030421).

Btw, how long is your querystring in total?  Request method+requested
file+parameters+version may not be longer than 256 chars.

/ Mikael

On Wed, 10 Sep 2003, Lars Andersson wrote:
> Hi Mikael,
> 
> Sorry for not being specific on the version and HW. I am using Nut/OS
> 3.3 on a rev-d board.
>
> I have found out that the "NutHttpGetParameterCount" function works fine
> and returns the correct number of parameters. It seams that the mpu
> makes weird things inside the loop. The output is different for the same
> query string.
>
> I have used the httpd.c and httpd.h files and not patched anything.
>
> Do you have any clue on how much memory this process requires compared
> to the original code. Could it be that I have not dedicated enough
> memory when starting the thread dong the processing?
> 
> I'll try this code in a simpler application than I am working on right
> now and see what happens.

_______________________________________________
En-Nut-Discussion mailing list
En-Nut-Discussion at egnite.de
http://www.egnite.de/mailman/listinfo/en-nut-discussion



More information about the En-Nut-Discussion mailing list