Mailing List Archive

BSDI compilation of apache .001
First off, a weirdness - I managed to compile apache without problem on
hyperreal (port 8000) but when the home page called two inline CGI scripts
(to randomize the images) I got a 500 server error. Diving in, I determined
that scripts that put "\r\n\r\n" inbetween the HTTP headers (CRLFCRLF in
other words) and the data produce a 500 server error, whereas those that just
put "\n\n" (LFLF) work fine. Any idea on what's causing this? I've been
using \r\n in all my scripts as that's what I thought the HTTP specs
required, so to not do that would be painful (but if the spec really is

The compilation on SGI went without a hitch, but I had to tweak a little bit
to get it to compile on BSDI (whereas stock NCSA compiles fine). Here's the
changes, which you can see in action in /export/apache/apache-tar-brian/:

util.c and stream.c - both referred to an errno "ETIME", which I couldn't
find in /usr/include/sys/errno.h in BSD. Apparently it's equivalent to
ETIMEDOUT (correct me if I'm wrong) so I changed a line like

errno = ETIME;

to

#if defined(BSD)
errno = ETIMEDOUT;
#else
errno = ETIME;
#endif

There were messages about "BSD already defined" and incompatible pointer
types. This is probably pretty basic to y'all, but I just want to double
check that that makes sense :)

Brian

--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--
brian@hotwired.com brian@hyperreal.com http://www.hotwired.com/Staff/brian/
Re: BSDI compilation of apache .001 [ In reply to ]
>
> (to randomize the images) I got a 500 server error. Diving in, I determined
> that scripts that put "\r\n\r\n" inbetween the HTTP headers (CRLFCRLF in

I use \r\n on all my headers too. That's what should be used, but
clients and servers are supposed to tolerate \n\n

Nobody complained about changing the send_fd function into
one returning a value, so I'll try that out.

rob
Re: BSDI compilation of apache .001 [ In reply to ]
On Mar 12, 9:02am, Robert S. Thau wrote:

} The Right Thing is for the server to change the script-supplied
} headers to internet EOL conventions from the Unix conventions, if the
} script supplies the latter (if only because almost every script out
} there just uses \n).

I think this is the "right thing" to do. A "\r\n" or a "\n" should
have the meaning of an EOL ot the server. The server should communicate
this back to the client.


Status update:

I've started going through the patches and getting code together.
Keep that code comming. I am using SunOS 4.1.4 as the base OS
for my integration, and I will also verify on Solaris 2.4, BSDI 1.1 and
BSDI 2.0 before releasing it to test. Verification is *not* full testing,
it means it compiles, runs, and seems to work. For all "B" catagory
items, it would be nice to have a "reproduced by" description or even
better some test code.

I am planning to get together an alpha release for people to hack
with on 3/19, and will hopefully follow with a 4/2 beta.
Re: BSDI compilation of apache .001 [ In reply to ]
Date: Sat, 11 Mar 1995 15:58:35 -0800 (PST)
From: Brian Behlendorf <brian@wired.com>
Precedence: bulk
Reply-To: new-httpd@hyperreal.com


First off, a weirdness - I managed to compile apache without problem on
hyperreal (port 8000) but when the home page called two inline CGI scripts
(to randomize the images) I got a 500 server error. Diving in, I determined
that scripts that put "\r\n\r\n" inbetween the HTTP headers (CRLFCRLF in
other words) and the data produce a 500 server error, whereas those that just
put "\n\n" (LFLF) work fine. Any idea on what's causing this? I've been
using \r\n in all my scripts as that's what I thought the HTTP specs
required, so to not do that would be painful (but if the spec really is

This is probably due to the change in scan_script_header to use
fgets() instead of the util.c getline() (the infamous single-character
read routine); something in EOL handling there is presumably broken.

The Right Thing is for the server to change the script-supplied
headers to internet EOL conventions from the Unix conventions, if the
script supplies the latter (if only because almost every script out
there just uses \n).

rst
Re: BSDI compilation of apache .001 [ In reply to ]
HP-UX and IRIX also both have both unistd.h and sys/time.h.

rst
Re: BSDI compilation of apache .001 [ In reply to ]
>From: rst@ai.mit.edu (Robert S. Thau)
>Date: Sun, 12 Mar 95 09:02:39 EST

> Date: Sat, 11 Mar 1995 15:58:35 -0800 (PST)
> From: Brian Behlendorf <brian@wired.com>
> Diving in, I determined that scripts that put "\r\n\r\n" inbetween the
> HTTP headers (CRLFCRLF in other words) and the data produce a 500 server
> error...
>This is probably due to the change in scan_script_header to use
>fgets() instead of the util.c getline() (the infamous single-character
>read routine); something in EOL handling there is presumably broken.
>
>The Right Thing is for the server to change the script-supplied
>headers to internet EOL conventions from the Unix conventions, if the
>script supplies the latter (if only because almost every script out
>there just uses \n).

Sorry about this, my fault. The top of scan_script_header should have read
int scan_script_header(FILE *f, FILE *fd) {
char w[MAX_STRING_LEN];
char *l;
int p;

while(1) {
/* why did this use getline, when we can use stdio buffered I/O?? */
/* maybe we should put a timeout on this. */
if (fgets(w, MAX_STRING_LEN-1, f) == NULL)
die(SERVER_ERROR,"httpd: malformed header from script",fd);
p = strlen(w);
if (p > 0 && w[p-1] == '\n')
{
if (p > 1 && w[p-2] == '\015') w[p-2] = '\0';
else w[p-1] = '\0';
}
...

I've tested this, and it fixes the problem.

David.
Re: BSDI compilation of apache .001 [ In reply to ]
> Date: Sat, 11 Mar 1995 15:58:35 -0800 (PST)
> From: Brian Behlendorf <brian@wired.com>
> ... Diving in, I determined that scripts that put "\r\n\r\n" inbetween the
> HTTP headers (CRLFCRLF in other words) and the data produce a 500 server
> error...
> ...
> util.c and stream.c - both referred to an errno "ETIME", which I couldn't
> find in /usr/include/sys/errno.h in BSD. Apparently it's equivalent to
> ETIMEDOUT (correct me if I'm wrong) so I changed a line like
>
> errno = ETIME;
>
> to
>
> #if defined(BSD)
> errno = ETIMEDOUT;
> #else
> errno = ETIME;
> #endif

There is no reason to make this conditional on BSD; it might as well use
ETIMEDOUT for all architectures.

I've updated my patch (patch.drtr-read) to fix both these problems, and have
uploaded it to hyperreal:httpd/patches/

Portability issues still outstanding:
stream.c needs unistd.h and sys/time.h.
Are these available on all unixes?
(I note that httpd.h only includes unistd.h if NEXT is defined)

I've checked OSF/1, Linux, Solaris, SunOs, BSD/386 and they all have these
two header files.

David.
Re: BSDI compilation of apache .001 [ In reply to ]
[David Robinson]
| There is no reason to make this conditional on BSD; it might as well use
| ETIMEDOUT for all architectures.
| Portability issues still outstanding:
| stream.c needs unistd.h and sys/time.h.

That's where GNU autoconf could come in handy, really :)
-- Nicolas

PS: I've written a log-file processor which replaces IP numbers
by resolved hostnames on the fly, using a DBM disk-cache.
Currently moving it to GDBM... anybody interested ?