[PATCH] httpd: Support configurable start page

Alex Landau landau_alex at yahoo.com
Wed Oct 17 11:45:03 UTC 2007


--- Denys Vlasenko <vda.linux at googlemail.com> wrote:

> On Wednesday 17 October 2007 10:56, Alex Landau wrote:
> > --- Alex Landau <landau_alex at yahoo.com> wrote:
> > 
> > > Hi,
> > > 
> > > The attached patch adds an option to set the default page to display for a URL like
> > > http://hostname/ instead of index.html. The option is compile-time selectable and
> the
> > > filename is config-file choosable. The file may also be a CGI script (if CGI is
> > > compiled
> > > in).
> > > 
> > > Any comments?
> 
> I removed dup() below:
> 
> cgi_io_loop_and_exit(proxy_fd, dup(proxy_fd), length);
> 
> Is it needed?

Yes, it is. cgi_io_loop_and_exit() expects 2 distinct file descriptors (ala pipe()) and
closes one of them to notify the CGI about an EOF in the postdata. This will close the
connection in the proxy case. I've put it back.

> 
> Also I edited code parts which looked like "if ((A = expr) == B) ... ",
> and removed trailing whitespace.
> 
> Here you allocate 8k buffer and copy there all headers from client:
> 
>         char *headers = xmalloc(IOBUF_SIZE);
>         ...
> 
> But you use it only if request happens to be one of the proxied
> requests:
> 
>         proxy_entry = find_proxy_entry(urlcopy);
>         if (proxy_entry != NULL) {
>                 ....
>                 write(proxy_fd, headers, headers_ptr - headers);
>                 write(proxy_fd, "\r\n", 2);
>                 cgi_io_loop_and_exit(proxy_fd, proxy_fd, length);
>         }
> 
> Can you check find_proxy_entry(urlcopy) earlier and do xmalloc
> and copying only if needed?
> 

Sure, how could I miss it? Thanks!

> I am attaching modified httpd.c, please base your further work on it.
> 

Ditto.

> Thanks Alex for your work.

I hope someone besides me will find these features useful.
:-)

> --
> vda
> 
Alex


      ____________________________________________________________________________________
Tonight's top picks. What will you watch tonight? Preview the hottest shows on Yahoo! TV.
http://tv.yahoo.com/ 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: httpd.c.bz2
Type: application/x-bzip
Size: 19175 bytes
Desc: 824490146-httpd.c.bz2
Url : http://lists.busybox.net/pipermail/busybox/attachments/20071017/4141a7a5/attachment-0002.bin 


More information about the busybox mailing list