# HG changeset patch # User Igor Sysoev # Date 1069311950 0 # Node ID 31824be1fc665afa653bad44f2ccd88c32f43ebb # Parent 71ce40b3c37bcde8d4d96c0332e542ce5e3912d6 nginx-0.0.1-2003-11-20-10:05:50 import; auto/configure diff --git a/auto/configure b/auto/configure new file mode 100755 --- /dev/null +++ b/auto/configure @@ -0,0 +1,12 @@ + +CC=cc +CPP='cc -E' + +echo > ngx_auto_config.h + +. auto/types/time_t + +. auto/types/uint64_t +. auto/types/uintptr_t + +. auto/types/socklen_t diff --git a/auto/types/socklen_t b/auto/types/socklen_t new file mode 100644 --- /dev/null +++ b/auto/types/socklen_t @@ -0,0 +1,28 @@ + +found=0 + +echo 'Checking for socklen_t' + +echo '#include ' > autotest.c +echo '#include ' >> autotest.c +echo 'int main() { socklen_t i = 0; return 0; }' >> autotest.c + +eval "${CC} -o autotest autotest.c > /dev/null 2>&1" + +if [ -x autotest ]; then + echo ' + socklen_t found' + found=1 +else + echo ' + socklen_t not found' + echo ' + uint32_t used' + type='typedef uint32_t socklen_t;' + found=2 +fi + +rm autotest* + + +if [ $found = 2 ]; then + echo $type >> ngx_auto_config.h + echo >> ngx_auto_config.h +fi diff --git a/auto/types/time_t b/auto/types/time_t new file mode 100644 --- /dev/null +++ b/auto/types/time_t @@ -0,0 +1,30 @@ + +echo "Checking for printf() time_t format" + +echo '#include ' > autotest.c +type=`${CPP} autotest.c | awk '/^typedef.*time_t/ {print \$2}'` +rm autotest.c + +case $type in + long) + echo ' + long: "%ld" used' + fmt='"%ld"' + ;; + + int) + echo ' + int: "%d" used' + fmt='"%d"' + ;; + + *) + echo "$0: error: unknown time_t definition: \"$type\"" + exit 1 + ;; + +esac + + +echo "#ifndef TIME_FMT" >> ngx_auto_config.h +echo "#define TIME_FMT $fmt" >> ngx_auto_config.h +echo "#endif" >> ngx_auto_config.h +echo >> ngx_auto_config.h diff --git a/auto/types/uint64_t b/auto/types/uint64_t new file mode 100644 --- /dev/null +++ b/auto/types/uint64_t @@ -0,0 +1,50 @@ + +found=0 + +echo 'Checking for uint64_t' + + echo '#include ' > autotest.c + echo 'int main() { uint64_t i = 0; return 0; }' >> autotest.c + + eval "${CC} -o autotest autotest.c > /dev/null 2>&1" + + if [ -x autotest ]; then + echo ' + uint64_t found' + found=1 + else + echo ' + uint64_t not found' + fi + + rm autotest* + + +if [ $found = 0 ]; then + + echo '#include ' > autotest.c + echo 'int main() { u_int64_t i = 0; return 0; }' >> autotest.c + + eval "${CC} -o autotest autotest.c > /dev/null 2>&1" + + if [ -x autotest ]; then + echo ' + u_int64_t used' + type='typedef u_int64_t uint64_t;' + found=2 + else + echo ' + u_int64_t not found' + fi + + rm autotest* + +fi + + +if [ $found = 0 ]; then + echo "$0: error: uint64_t not found" + exit 1 +fi + + +if [ $found = 2 ]; then + echo $type >> ngx_auto_config.h + echo >> ngx_auto_config.h +fi diff --git a/auto/types/uintptr_t b/auto/types/uintptr_t new file mode 100644 --- /dev/null +++ b/auto/types/uintptr_t @@ -0,0 +1,45 @@ + +found=0 + +echo 'Checking for uintptr_t' + + echo '#include ' > autotest.c + echo 'int main() { uintptr_t i = 0; return i; }' >> autotest.c + + eval "${CC} -o autotest autotest.c > /dev/null 2>&1" + + if [ -x autotest ]; then + echo ' + uintptr_t found' + found=1 + else + echo ' + uintptr_t not found' + fi + + rm autotest* + + +if [ $found = 0 ]; then + echo 'int main() { printf("%d", 8 * sizeof(void *)); return 0; }' \ + > autotest.c + eval "${CC} -o autotest autotest.c > /dev/null 2>&1" + + if [ -x autotest ]; then + type="uint`./autotest`_t" + echo " + $type used" + type="typedef $type uintptr_t;" + found=2 + fi +fi + + +if [ $found = 0 ]; then + echo "$0: error: uintptr_t not found" + exit 1 +fi + + +if [ $found = 2 ]; then + echo $type >> ngx_auto_config.h + echo >> ngx_auto_config.h +fi + diff --git a/src/core/ngx_auto_config.h b/src/core/ngx_auto_config.h deleted file mode 100644 --- a/src/core/ngx_auto_config.h +++ /dev/null @@ -1,7 +0,0 @@ - -#ifndef OFF_EQUAL_PTR -#define OFF_EQUAL_PTR 0 -#endif - - -#define NGX_PAGE_SIZE 4096 diff --git a/src/core/ngx_connection.h b/src/core/ngx_connection.h --- a/src/core/ngx_connection.h +++ b/src/core/ngx_connection.h @@ -62,9 +62,6 @@ struct ngx_connection_s { off_t sent; -#if 0 - void (*handler)(ngx_connection_t *c); -#endif void *ctx; void *servers; @@ -72,11 +69,6 @@ struct ngx_connection_s { ngx_log_t *log; ngx_pool_t *pool; -#if 0 - int pool_size; - - int family; -#endif struct sockaddr *sockaddr; socklen_t socklen; @@ -87,15 +79,7 @@ struct ngx_connection_s { socklen_t local_socklen; #endif -#if 0 - int addr; - int addr_text_max_len; -#endif - ngx_hunk_t *buffer; -#if 0 - unsigned int post_accept_timeout; -#endif int number; @@ -108,62 +92,7 @@ struct ngx_connection_s { }; - - - -#if 0 -cached file - int fd; -2 unused, -1 closed (but read or mmaped), >=0 open - char *name; - - void *buf; addr if read or mmaped - aiocb* if aio_read - OVERLAPPED if TransmitFile or TransmitPackets - NULL if sendfile - - size_t buf_size; for plain read - off_t offset; for plain read - - size_t size; - time_t mod; - char *last_mod; "Sun, 17 Mar 2002 19:39:50 GMT" - char *etag; ""a6d08-1302-3c94f106"" - char *len; "4866" - -EV_VNODE should notify by some signal if diretory tree is changed - or stat if aged >= N seconds (big enough) -#endif - - -#if 0 -typedef struct { - ssize_t (*recv)(ngx_connection_t *c, char *buf, size_t size); - void *dummy_recv_chain; - void *dummy_send; - ngx_chain_t *(*send_chain)(ngx_connection_t *c, ngx_chain_t *in); -} ngx_os_io_t; -#endif - - - -extern ngx_array_t ngx_listening_sockets; extern ngx_os_io_t ngx_io; -extern ngx_chain_t *(*ngx_write_chain_proc) - (ngx_connection_t *c, ngx_chain_t *in); - - -ssize_t ngx_recv_chain(ngx_connection_t *c, ngx_chain_t *ce); -#if 0 -ngx_chain_t *ngx_write_chain(ngx_connection_t *c, ngx_chain_t *in, off_t flush); -#endif - - -/* TODO: move it to OS specific file */ -#if (__FreeBSD__) -ngx_chain_t *ngx_aio_write_chain(ngx_connection_t *c, ngx_chain_t *in); -#endif - - #endif /* _NGX_CONNECTION_H_INCLUDED_ */ diff --git a/src/event/ngx_event_accept.c b/src/event/ngx_event_accept.c --- a/src/event/ngx_event_accept.c +++ b/src/event/ngx_event_accept.c @@ -85,7 +85,7 @@ void ngx_event_accept(ngx_event_t *ev) ngx_log_error(NGX_LOG_ALERT, ev->log, 0, "accept() on %s returned socket #%d while " "only %d connections was configured, " - "sleeping for 1 second", + "closing the connection", ls->listening->addr_text.data, s, ecf->connections); if (ngx_close_socket(s) == -1) { @@ -93,7 +93,7 @@ void ngx_event_accept(ngx_event_t *ev) ngx_close_socket_n "failed"); } - ngx_msleep(1000); + /* TODO: disable temporary accept() event */ ngx_destroy_pool(pool); return; @@ -225,11 +225,9 @@ void ngx_event_accept(ngx_event_t *ev) ls->listening->handler(c); -#if 0 if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) { ev->available--; } -#endif accepted++; diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c --- a/src/http/ngx_http_request.c +++ b/src/http/ngx_http_request.c @@ -157,7 +157,7 @@ ngx_log_debug(rev->log, "IN: %08x" _ in_ if (in_port->addrs.nelts > 1) { /* - * there're the several addresses on this port and one of them + * There're the several addresses on this port and one of them * is "*:port" so getsockname() is needed to determine * the server address. * AcceptEx() already gave this address. @@ -346,10 +346,12 @@ static void ngx_http_process_request_lin r->request_line.len = r->request_end - r->request_start; - /* if the large client headers are enabled then - we need to copy a request line */ + if (cscf->large_client_header) { - if (cscf->large_client_header) { + /* + * if the large client headers are enabled then + * we need to copy a request line + */ r->request_line.data = ngx_palloc(r->pool, r->request_line.len + 1); if (r->request_line.data == NULL) { @@ -366,9 +368,11 @@ static void ngx_http_process_request_lin r->request_line.data[r->request_line.len] = '\0'; } - /* copy URI extention if it exists */ if (r->uri_ext) { + + /* copy URI extention */ + if (r->args_start) { r->exten.len = r->args_start - 1 - r->uri_ext; } else { @@ -384,9 +388,10 @@ static void ngx_http_process_request_lin ngx_cpystrn(r->exten.data, r->uri_ext, r->exten.len + 1); } - /* copy URI arguments if they exist */ + if (r->args_start && r->uri_end > r->args_start) { - if (r->args_start && r->uri_end > r->args_start) { + /* copy URI arguments */ + r->args.len = r->uri_end - r->args_start; if (!(r->args.data = ngx_palloc(r->pool, r->args.len + 1))) { @@ -446,8 +451,8 @@ static void ngx_http_process_request_lin /* * If it's a pipelined request and a request line is not complete - * then we need to copy it to the start of the r->header_in hunk. - * We need to copy it here only if the large client headers + * then we have to copy it to the start of the r->header_in hunk. + * We have to copy it here only if the large client headers * are enabled otherwise a request line had been already copied * to the start of the r->header_in hunk in ngx_http_set_keepalive(). */ diff --git a/src/os/unix/ngx_freebsd_config.h b/src/os/unix/ngx_freebsd_config.h --- a/src/os/unix/ngx_freebsd_config.h +++ b/src/os/unix/ngx_freebsd_config.h @@ -27,18 +27,6 @@ #include -/* TODO: autoconf */ -#if __FreeBSD_version < 300007 -typedef u_int64_t uint64_t; -typedef u_int32_t uintptr_t; -#endif - - -/* TODO: autoconf ??? */ -#if __FreeBSD_version < 330002 /* exactly */ -typedef uint32_t socklen_t; -#endif - /* TODO: autoconf */ #if (i386) @@ -55,7 +43,9 @@ typedef uint32_t socklen_t; #endif +#if 0 #define TIME_FMT "%ld" +#endif #define PID_FMT "%d" #define RLIM_FMT "%lld"