aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2002-12-15 21:08:04 +0000
committerIgor Sysoev <igor@sysoev.ru>2002-12-15 21:08:04 +0000
commit5eef618ed671c55bc1244652cb49afef224c833c (patch)
tree593b11f615eb39e824c8e8d45ada176ae264de0d /src
parent6e4bca966e723a2162a0f183f4f520115e0fba32 (diff)
downloadnginx-5eef618ed671c55bc1244652cb49afef224c833c.tar.gz
nginx-5eef618ed671c55bc1244652cb49afef224c833c.zip
nginx-0.0.1-2002-12-16-00:08:04 import
Diffstat (limited to 'src')
-rw-r--r--src/core/ngx_config.h4
-rw-r--r--src/core/ngx_connection.h3
-rw-r--r--src/core/ngx_log.c2
-rw-r--r--src/core/ngx_sendfile.c (renamed from src/os/unix/ngx_sendfile.h)17
-rw-r--r--src/core/ngx_sendfile.h (renamed from src/os/win32/ngx_sendfile.h)0
-rw-r--r--src/event/ngx_event.c1
-rw-r--r--src/http/modules/ngx_http_log_handler.c32
-rw-r--r--src/http/ngx_http_core.c16
-rw-r--r--src/os/unix/ngx_time.c2
-rw-r--r--src/os/win32/ngx_files.h3
10 files changed, 55 insertions, 25 deletions
diff --git a/src/core/ngx_config.h b/src/core/ngx_config.h
index 09f73eb34..cc650c1f0 100644
--- a/src/core/ngx_config.h
+++ b/src/core/ngx_config.h
@@ -80,6 +80,10 @@
#define CRLF "\x0d\x0a"
+#ifndef INET_ADDRSTRLEN
+#define INET_ADDRSTRLEN 16
+#endif
+
#if defined SO_ACCEPTFILTER || defined TCP_DEFER_ACCEPT
diff --git a/src/core/ngx_connection.h b/src/core/ngx_connection.h
index 0ff09ffdf..1c19aa374 100644
--- a/src/core/ngx_connection.h
+++ b/src/core/ngx_connection.h
@@ -3,8 +3,9 @@
#include <ngx_socket.h>
#include <ngx_log.h>
-#include <ngx_hunk.h>
#include <ngx_alloc.h>
+#include <ngx_hunk.h>
+#include <ngx_array.h>
#include <ngx_string.h>
#include <ngx_server.h>
diff --git a/src/core/ngx_log.c b/src/core/ngx_log.c
index 78459e348..244edc33e 100644
--- a/src/core/ngx_log.c
+++ b/src/core/ngx_log.c
@@ -38,7 +38,7 @@ void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err,
ngx_localtime(&tm);
len = ngx_snprintf(errstr, sizeof(errstr), "%4d/%02d/%02d %02d:%02d:%02d",
- tm.ngx_tm_year + 1900, tm.ngx_tm_mon, tm.ngx_tm_mday,
+ tm.ngx_tm_year, tm.ngx_tm_mon, tm.ngx_tm_mday,
tm.ngx_tm_hour, tm.ngx_tm_min, tm.ngx_tm_sec);
len += ngx_snprintf(errstr + len, sizeof(errstr) - len - 1,
diff --git a/src/os/unix/ngx_sendfile.h b/src/core/ngx_sendfile.c
index c9a59235f..bffd29c0c 100644
--- a/src/os/unix/ngx_sendfile.h
+++ b/src/core/ngx_sendfile.c
@@ -1,11 +1,8 @@
-#ifndef _NGX_SENDFILE_H_INCLUDED_
-#define _NGX_SENDFILE_H_INCLUDED_
-
-#include <ngx_types.h>
-#include <ngx_files.h>
-#include <ngx_socket.h>
+#include <ngx_config.h>
+#include <ngx_core.h>
#include <ngx_log.h>
+#include <ngx_socket.h>
#include <ngx_sendv.h>
int ngx_sendfile(ngx_socket_t s,
@@ -13,7 +10,11 @@ int ngx_sendfile(ngx_socket_t s,
ngx_fd_t fd, off_t offset, size_t nbytes,
ngx_iovec_t *trailers, int trl_cnt,
off_t *sent,
- ngx_log_t *log);
+ ngx_log_t *log)
+{
+ ngx_log_error(NGX_LOG_INFO, log, 0,
+ "ngx_sendfile: sendfile is not implemented");
-#endif /* _NGX_SENDFILE_H_INCLUDED_ */
+ return NGX_ERROR;
+}
diff --git a/src/os/win32/ngx_sendfile.h b/src/core/ngx_sendfile.h
index a80750bef..a80750bef 100644
--- a/src/os/win32/ngx_sendfile.h
+++ b/src/core/ngx_sendfile.h
diff --git a/src/event/ngx_event.c b/src/event/ngx_event.c
index 2d68af2a0..763b8f8d2 100644
--- a/src/event/ngx_event.c
+++ b/src/event/ngx_event.c
@@ -5,6 +5,7 @@
#include <ngx_string.h>
#include <ngx_log.h>
#include <ngx_alloc.h>
+#include <ngx_array.h>
#include <ngx_listen.h>
#include <ngx_connection.h>
#include <ngx_event.h>
diff --git a/src/http/modules/ngx_http_log_handler.c b/src/http/modules/ngx_http_log_handler.c
index 56ea8419e..4937ed0b8 100644
--- a/src/http/modules/ngx_http_log_handler.c
+++ b/src/http/modules/ngx_http_log_handler.c
@@ -20,15 +20,19 @@ int ngx_http_log_handler(ngx_http_request_t *r)
char *line, *p;
ngx_tm_t tm;
+ ngx_log_debug(r->connection->log, "log handler");
+
+ /* %a, 20:%c, 22:%d, 3:%s, 20:%b, 5*" ", "2/1: "\r\n" */
#if (WIN32)
- len = 2 + 22 + 3 + 20 + 5 + 20 + 2;
+ len = 2 + 20 + 22 + 3 + 20 + 5 + + 2;
#else
- len = 2 + 22 + 3 + 20 + 5 + 20 + 1;
+ len = 2 + 20 + 22 + 3 + 20 + 5 + + 1;
#endif
len += r->connection->addr_text.len;
len += r->request_line.len;
+ ngx_log_debug(r->connection->log, "log handler: %d" _ len);
ngx_test_null(line, ngx_palloc(r->pool, len), NGX_ERROR);
p = line;
@@ -38,18 +42,30 @@ int ngx_http_log_handler(ngx_http_request_t *r)
*p++ = ' ';
+ p += ngx_snprintf(p, 21, "%u", r->connection->number);
+
+ *p++ = ' ';
+
+ *p = '\0';
+ ngx_log_debug(r->connection->log, "log handler: %s" _ line);
+
ngx_localtime(&tm);
+ ngx_log_debug(r->connection->log, "log handler: %s" _ line);
+
*p++ = '[';
p += ngx_snprintf(p, 21, "%02d/%s/%d:%02d:%02d:%02d",
- tm.ngx_tm_mday, months[tm.ngx_tm_mon],
- tm.ngx_tm_year + 1900,
+ tm.ngx_tm_mday, months[tm.ngx_tm_mon - 1],
+ tm.ngx_tm_year,
tm.ngx_tm_hour, tm.ngx_tm_min, tm.ngx_tm_sec);
*p++ = ']';
*p++ = ' ';
+ *p = '\0';
+ ngx_log_debug(r->connection->log, "log handler: %s" _ line);
+
*p++ = '"';
ngx_memcpy(p, r->request_line.data, r->request_line.len);
p += r->request_line.len;
@@ -63,9 +79,8 @@ int ngx_http_log_handler(ngx_http_request_t *r)
p += ngx_snprintf(p, 21, QD_FMT, r->connection->sent);
- *p++ = ' ';
-
- p += ngx_snprintf(p, 21, "%u", r->connection->number);
+ *p = '\0';
+ ngx_log_debug(r->connection->log, "log handler: %s" _ line);
#if (WIN32)
*p++ = CR; *p++ = LF;
@@ -73,6 +88,9 @@ int ngx_http_log_handler(ngx_http_request_t *r)
*p++ = LF;
#endif
+ *p = '\0';
+ ngx_log_debug(r->connection->log, "log handler: %s" _ line);
+
write(1, line, len);
return NGX_OK;
diff --git a/src/http/ngx_http_core.c b/src/http/ngx_http_core.c
index a0555e378..e4f97eef7 100644
--- a/src/http/ngx_http_core.c
+++ b/src/http/ngx_http_core.c
@@ -105,10 +105,10 @@ static int ngx_http_core_translate_handler(ngx_http_request_t *r)
ngx_log_debug(r->connection->log, "HTTP filename: '%s'" _
r->file.name.data);
-#if (WIN32)
+#if (WIN9X)
- /* There is no way to open file or directory in Win32 with
- one syscall: CreateFile() returns ERROR_ACCESS_DENIED on directory,
+ /* There is no way to open file or directory in Win9X with
+ one syscall: Win9X has not FILE_FLAG_BACKUP_SEMANTICS flag.
so we need to check its type before opening */
#if 0 /* OLD: ngx_file_type() is to be removed */
@@ -138,7 +138,7 @@ static int ngx_http_core_translate_handler(ngx_http_request_t *r)
if (r->file.fd == NGX_INVALID_FILE) {
err = ngx_errno;
ngx_log_error(NGX_LOG_ERR, r->connection->log, ngx_errno,
- "ngx_http_static_handler: "
+ "ngx_http_core_handler: "
ngx_open_file_n " %s failed", r->file.name.data);
if (err == NGX_ENOENT)
@@ -150,12 +150,12 @@ static int ngx_http_core_translate_handler(ngx_http_request_t *r)
if (!r->file.info_valid) {
if (ngx_stat_fd(r->file.fd, &r->file.info) == NGX_FILE_ERROR) {
ngx_log_error(NGX_LOG_ERR, r->connection->log, ngx_errno,
- "ngx_http_static_handler: "
+ "ngx_http_core_handler: "
ngx_stat_fd_n " %s failed", r->file.name.data);
if (ngx_close_file(r->file.fd) == NGX_FILE_ERROR)
ngx_log_error(NGX_LOG_ERR, r->connection->log, ngx_errno,
- "ngx_http_static_handler: "
+ "ngx_http_core_handler: "
ngx_close_file_n " %s failed", r->file.name.data);
return NGX_HTTP_INTERNAL_SERVER_ERROR;
@@ -168,10 +168,10 @@ static int ngx_http_core_translate_handler(ngx_http_request_t *r)
if (ngx_is_dir(r->file.info)) {
ngx_log_debug(r->connection->log, "HTTP DIR: '%s'" _ r->file.name.data);
-#if !(WIN32)
+#if !(WIN9X)
if (ngx_close_file(r->file.fd) == NGX_FILE_ERROR)
ngx_log_error(NGX_LOG_ERR, r->connection->log, ngx_errno,
- "ngx_http_static_handler: "
+ "ngx_http_core_handler: "
ngx_close_file_n " %s failed", r->file.name.data);
#endif
diff --git a/src/os/unix/ngx_time.c b/src/os/unix/ngx_time.c
index 5dfcb63f2..26ef6462d 100644
--- a/src/os/unix/ngx_time.c
+++ b/src/os/unix/ngx_time.c
@@ -6,6 +6,8 @@ void ngx_localtime(ngx_tm_t *tm)
{
time_t clock = time(NULL);
localtime_r(&clock, tm);
+ tm->ngx_tm_mon++;
+ tm->ngx_tm_year += 1900;
}
u_int ngx_msec(void)
diff --git a/src/os/win32/ngx_files.h b/src/os/win32/ngx_files.h
index 8cd58efc7..f5e50cc9f 100644
--- a/src/os/win32/ngx_files.h
+++ b/src/os/win32/ngx_files.h
@@ -22,7 +22,10 @@ typedef BY_HANDLE_FILE_INFORMATION ngx_file_info_t;
#define ngx_open_file(name, flags) \
CreateFile(name, flags, \
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, \
+ NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL)
+/*
NULL, OPEN_EXISTING, 0, NULL)
+*/
#define ngx_open_file_n "CreateFile()"