[En-Nut-Discussion] Duplicate code in httpd.c and ssi.c

Ole Reinhardt ole.reinhardt at embedded-it.de
Wed May 14 10:16:14 CEST 2008


Hi Thiago,

>    Actually it's probably non-related. I still have to figure out
> what's wrong, if it was the ethernut upgrade or something else. I have
> an index.html that redirects to index.asp (my code is older than the
> patch that introduces index.asp as a valid default page).
>    So, I get to load index.html but not index.asp. Typing the cgi urls
> that I have directly also doesn't help. The browser just sits there
> "loading" indefinitly.

Strange, try to trace your network traffic with wireshark to see at what
point the communication stops. Could be a stack overflow anywhere in
your code?

> Yeah, at first I thought it might be the switch from HTTP 1.0 to HTTP
> 1.1 and it's persistent connections. I might just change back the
> defines to test that out.

Could be possible. Unfortunatly I did not use the new code yet.

> I wasn't aware. But, either way, it's best practice to match
> NutHeapAlloc with NutHeapFree and malloc with free instead of mixing
> them up.

Right. We should avoid malloc / free and use NutHeapAlloc / NutHeapFree
instead. That would be more consistent.

> My proposal isn't really to fix a problem, but just rather get rid of
> a duplicate function. Should reduce code size a little bit. Anyway, I
> produced a patch that I'm attaching to this mail. Will commit if
> everything is in order.

I'm wondering why you remove the DestroyRequestInfo in both files? 
Btw: Those two versions of DestroyRequestInfo are different! The one in
httpd.c frees one more member of the request struct.

So remove the right one :)

Perhaps the best way would be to place some common functions into a
httpd_commom.c. There are some more functions I found that are used in
ssi.c and are included from httpd.c. Cross referencing functions between
c files is not a realy good coding style :)

Regards,

Ole Reinhardt

-- 
 _____________________________________________________________
|                                                             |
| Embedded-IT          Hard- und Softwarelösungen             |
|                                                             |
| Ole Reinhardt        Tel. / Fax:        +49 (0)271  7420433 |
| Luisenstraße 29      Mobil:             +49 (0)177  7420433 |
| 57076 Siegen         eMail:    ole.reinhardt at embedded-it.de |
| Germany              Web:         http://www.embedded-it.de |
|                      UstID / VAT:       DE198944716         |
|_____________________________________________________________|




More information about the En-Nut-Discussion mailing list