Skip to content

Commit

Permalink
nginx-0.1.0-2004-10-04-00:02:06 import
Browse files Browse the repository at this point in the history
  • Loading branch information
igorsysoev committed Oct 3, 2004
1 parent 8035fd2 commit aad1b89
Show file tree
Hide file tree
Showing 16 changed files with 218 additions and 139 deletions.
8 changes: 3 additions & 5 deletions src/core/nginx.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ ngx_module_t ngx_core_module = {
ngx_core_commands, /* module directives */
NGX_CORE_MODULE, /* module type */
NULL, /* init module */
NULL /* init child */
NULL /* init process */
};


Expand Down Expand Up @@ -146,10 +146,6 @@ int main(int argc, char *const *argv)

if (ngx_test_config) {
log->log_level = NGX_LOG_INFO;
} else {
if (ngx_log_init_error_log() == NGX_ERROR) {
return 1;
}
}

if (ngx_os_init(log) == NGX_ERROR) {
Expand Down Expand Up @@ -183,6 +179,8 @@ int main(int argc, char *const *argv)
return 0;
}

ngx_os_status(cycle->log);

ngx_cycle = cycle;

ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
Expand Down
9 changes: 7 additions & 2 deletions src/core/ngx_conf_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ static char *ngx_conf_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
return NGX_CONF_ERROR;
}

ngx_log_error(NGX_LOG_INFO, cf->log, 0, "include %s", file.data);
ngx_log_debug1(NGX_LOG_DEBUG_CORE, cf->log, 0, "include %s", file.data);

return ngx_conf_parse(cf, &file);
}
Expand Down Expand Up @@ -597,6 +597,11 @@ ngx_open_file_t *ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name)
ngx_list_part_t *part;
ngx_open_file_t *file;

#if (NGX_SUPPRESS_WARN)
full.len = 0;
full.data = NULL;
#endif

if (name) {
full = *name;

Expand Down Expand Up @@ -637,7 +642,7 @@ ngx_open_file_t *ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name)
file->name = full;

} else {
file->fd = STDERR_FILENO;
file->fd = ngx_stderr_fileno;
file->name.len = 0;
file->name.data = NULL;
}
Expand Down
44 changes: 23 additions & 21 deletions src/core/ngx_cycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,24 +328,6 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)
}
}

#if !(WIN32)

if (!failed && !ngx_test_config && cycle->log->file->fd != STDERR_FILENO) {

ngx_log_debug3(NGX_LOG_DEBUG_CORE, log, 0,
"dup2: %0X %d \"%s\"",
cycle->log->file,
cycle->log->file->fd, cycle->log->file->name.data);

if (dup2(cycle->log->file->fd, STDERR_FILENO) == NGX_ERROR) {
ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
"dup2(STDERR) failed");
failed = 1;
}
}

#endif

if (failed) {

/* rollback the new cycle configuration */
Expand All @@ -364,7 +346,9 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)
i = 0;
}

if (file[i].fd == NGX_INVALID_FILE) {
if (file[i].fd == NGX_INVALID_FILE
|| file[i].fd == ngx_stderr_fileno)
{
continue;
}

Expand Down Expand Up @@ -400,8 +384,26 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)

/* commit the new cycle configuration */

pool->log = cycle->log;
#if !(WIN32)

if (!ngx_test_config && cycle->log->file->fd != STDERR_FILENO) {

ngx_log_debug3(NGX_LOG_DEBUG_CORE, log, 0,
"dup2: %0X %d \"%s\"",
cycle->log->file,
cycle->log->file->fd, cycle->log->file->name.data);

if (dup2(cycle->log->file->fd, STDERR_FILENO) == NGX_ERROR) {
ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
"dup2(STDERR) failed");
/* fatal */
exit(1);
}
}

#endif

pool->log = cycle->log;

for (i = 0; ngx_modules[i]; i++) {
if (ngx_modules[i]->init_module) {
Expand Down Expand Up @@ -446,7 +448,7 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)
i = 0;
}

if (file[i].fd == NGX_INVALID_FILE) {
if (file[i].fd == NGX_INVALID_FILE || file[i].fd == ngx_stderr_fileno) {
continue;
}

Expand Down
13 changes: 10 additions & 3 deletions src/core/ngx_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,16 @@ ngx_log_t *ngx_log_init_stderr()
{
#if (WIN32)

ngx_stderr.fd = GetStdHandle(STD_ERROR_HANDLE);
ngx_stderr_fileno = GetStdHandle(STD_ERROR_HANDLE);
ngx_stderr.fd = ngx_stderr_fileno;

if (ngx_stderr_fileno == NGX_INVALID_FILE) {

if (ngx_stderr.fd == NGX_INVALID_FILE) {
/* TODO: where can we log error ? */

return NULL;

} else if (ngx_stderr.fd == NULL) {
} else if (ngx_stderr_fileno == NULL) {

/* there are no associated standard handles */

Expand All @@ -256,6 +259,8 @@ ngx_log_t *ngx_log_init_stderr()
}


#if 0

ngx_int_t ngx_log_init_error_log()
{
ngx_fd_t fd;
Expand Down Expand Up @@ -299,6 +304,8 @@ ngx_int_t ngx_log_init_error_log()
return NGX_OK;
}

#endif


ngx_log_t *ngx_log_create_errlog(ngx_cycle_t *cycle, ngx_array_t *args)
{
Expand Down
2 changes: 2 additions & 0 deletions src/core/ngx_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ void ngx_assert_core(ngx_log_t *log, const char *fmt, ...);
#define ngx_log_copy_log(new, old) ngx_memcpy(new, old, sizeof(ngx_log_t))

ngx_log_t *ngx_log_init_stderr();
#if 0
ngx_int_t ngx_log_init_error_log();
#endif
ngx_log_t *ngx_log_create_errlog(ngx_cycle_t *cycle, ngx_array_t *args);
char *ngx_set_error_log_levels(ngx_conf_t *cf, ngx_log_t *log);

Expand Down
7 changes: 0 additions & 7 deletions src/http/ngx_http_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ static char *client_header_errors[] = {

"client %s sent invalid header, URL: %s",
"client %s sent too long header line, URL: %s",
"client %s sent too many headers, URL: %s",
"client %s sent HTTP/1.1 request without \"Host\" header, URL: %s",
"client %s sent invalid \"Content-Length\" header, URL: %s",
"client %s sent POST method without \"Content-Length\" header, URL: %s",
Expand Down Expand Up @@ -759,12 +758,6 @@ static void ngx_http_process_request_headers(ngx_event_t *rev)
}
}

if (r->headers_n > 100) {
ngx_http_client_error(r, NGX_HTTP_PARSE_TOO_MANY_HEADERS,
NGX_HTTP_BAD_REQUEST);
return;
}

rc = ngx_http_parse_header_line(r, r->header_in);

if (rc == NGX_OK) {
Expand Down
1 change: 0 additions & 1 deletion src/http/ngx_http_request.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#define NGX_HTTP_PARSE_HEADER_ERROR 14
#define NGX_HTTP_PARSE_INVALID_HEADER 14
#define NGX_HTTP_PARSE_TOO_LONG_HEADER 15
#define NGX_HTTP_PARSE_TOO_MANY_HEADERS 16
#define NGX_HTTP_PARSE_NO_HOST_HEADER 17
#define NGX_HTTP_PARSE_INVALID_CL_HEADER 18
#define NGX_HTTP_PARSE_POST_WO_CL_HEADER 19
Expand Down
5 changes: 3 additions & 2 deletions src/os/unix/ngx_freebsd.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ ngx_chain_t *ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
extern int ngx_freebsd_kern_osreldate;
extern int ngx_freebsd_hw_ncpu;
extern int ngx_freebsd_net_inet_tcp_sendspace;
extern int ngx_freebsd_sendfile_nbytes_bug;
extern int ngx_freebsd_kern_ipc_zero_copy_send;
extern int ngx_freebsd_use_tcp_nopush;

extern ngx_uint_t ngx_freebsd_sendfile_nbytes_bug;
extern ngx_uint_t ngx_freebsd_use_tcp_nopush;


#endif /* _NGX_FREEBSD_H_INCLUDED_ */
Loading

0 comments on commit aad1b89

Please sign in to comment.