nginx-0.0.1-2002-12-15-09:25:09 import
diff --git a/src/core/nginx.c b/src/core/nginx.c
index b33ce29..e654e7e 100644
--- a/src/core/nginx.c
+++ b/src/core/nginx.c
@@ -32,6 +32,8 @@
ngx_pool_t *ngx_pool;
+int ngx_connection_counter;
+
ngx_array_t *ngx_listening_sockets;
@@ -43,7 +45,9 @@
ngx_pool = ngx_create_pool(16 * 1024, &ngx_log);
/* */
+#if !(WIN32)
ngx_set_signals(&ngx_log);
+#endif
ngx_init_sockets(&ngx_log);
@@ -73,6 +77,7 @@
return 0;
}
+#if !(WIN32)
static void ngx_set_signals(ngx_log_t *log)
{
struct sigaction sa;
@@ -86,6 +91,7 @@
exit(1);
}
}
+#endif
static void ngx_open_listening_sockets(ngx_log_t *log)
{
diff --git a/src/core/nginx.h b/src/core/nginx.h
index 30562c0..94d678f 100644
--- a/src/core/nginx.h
+++ b/src/core/nginx.h
@@ -5,4 +5,7 @@
#define NGINX_VER "nginx/0.0.1"
+extern int ngx_connection_counter;
+
+
#endif /* _NGINX_H_INCLUDED_ */
diff --git a/src/core/ngx_alloc.c b/src/core/ngx_alloc.c
index 67adfcb..36ad505 100644
--- a/src/core/ngx_alloc.c
+++ b/src/core/ngx_alloc.c
@@ -3,6 +3,7 @@
#include <ngx_errno.h>
#include <ngx_log.h>
+#include <ngx_string.h>
#include <ngx_alloc.h>
@@ -15,7 +16,7 @@
ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
"malloc() %d bytes failed", size);
- ngx_log_debug(log, "malloc: %x:%d" _ p _ size);
+ ngx_log_debug(log, "malloc: %08x:%d" _ p _ size);
return p;
}
@@ -52,12 +53,12 @@
ngx_pool_large_t *l;
for (l = pool->large; l; l = l->next) {
- ngx_log_debug(pool->log, "free: %x" _ l->alloc);
+ ngx_log_debug(pool->log, "free: %08x" _ l->alloc);
free(l->alloc);
}
for (p = pool, n = pool->next; /* void */; p = n, n = n->next) {
- ngx_log_debug(pool->log, "free: %x" _ p);
+ ngx_log_debug(pool->log, "free: %08x" _ p);
free(p);
if (n == NULL)
@@ -74,9 +75,10 @@
if (size <= NGX_MAX_ALLOC_FROM_POOL) {
for (p = pool, n = pool->next; /* void */; p = n, n = n->next) {
- if ((size_t) (p->end - p->last) >= size) {
- m = p->last;
- p->last += size;
+ if ((size_t) (p->end - ngx_align(p->last)) >= size) {
+ m = ngx_align(p->last);
+ p->last = ngx_align(p->last);
+ p->last += size ;
return m;
}
diff --git a/src/core/ngx_config.h b/src/core/ngx_config.h
index f7223fa..09f73eb 100644
--- a/src/core/ngx_config.h
+++ b/src/core/ngx_config.h
@@ -12,6 +12,13 @@
#define FD_SETSIZE 1024
+/* auto_conf */
+#define NGX_ALIGN (4 - 1)
+#define NGX_ALIGN_TYPE unsigned
+
+#define ngx_align(p) (char *) (((NGX_ALIGN_TYPE) p + NGX_ALIGN) & ~NGX_ALIGN)
+
+
#ifdef _WIN32
#define WIN32 1
@@ -25,9 +32,6 @@
#define ngx_inline __inline
-#define ngx_memzero ZeroMemory
-
-#define ngx_close_socket closesocket
#ifndef HAVE_INHERITED_NONBLOCK
#define HAVE_INHERITED_NONBLOCK 1
@@ -66,9 +70,6 @@
#define ngx_inline inline
-#define ngx_memzero bzero
-
-#define ngx_close_socket close
#endif /* POSIX */
diff --git a/src/core/ngx_connection.h b/src/core/ngx_connection.h
index b486f4b..0ff09ff 100644
--- a/src/core/ngx_connection.h
+++ b/src/core/ngx_connection.h
@@ -44,6 +44,8 @@
ngx_hunk_t *buffer;
unsigned int post_accept_timeout;
+ int number;
+
unsigned unexpected_eof:1;
};
diff --git a/src/core/ngx_file.h b/src/core/ngx_file.h
index 0d68386..d32c89b 100644
--- a/src/core/ngx_file.h
+++ b/src/core/ngx_file.h
@@ -4,12 +4,18 @@
#include <ngx_files.h>
#include <ngx_log.h>
+#include <ngx_string.h>
typedef struct ngx_file_s ngx_file_t;
struct ngx_file_s {
- ngx_fd_t fd;
- ngx_log_t *log;
+ ngx_fd_t fd;
+ ngx_str_t name;
+ ngx_file_info_t info;
+
+ ngx_log_t *log;
+
+ unsigned info_valid:1;
};
diff --git a/src/core/ngx_inet.c b/src/core/ngx_inet.c
new file mode 100644
index 0000000..aba990b
--- /dev/null
+++ b/src/core/ngx_inet.c
@@ -0,0 +1,18 @@
+
+#include <ngx_config.h>
+#include <ngx_string.h>
+#include <ngx_inet.h>
+
+
+size_t ngx_inet_ntop(int family, char *addr, char *text, size_t len)
+{
+ if (family != AF_INET)
+ return 0;
+
+ return ngx_snprintf(text, len > INET_ADDRSTRLEN ? INET_ADDRSTRLEN : len,
+ "%u.%u.%u.%u",
+ (unsigned char) addr[0],
+ (unsigned char) addr[1],
+ (unsigned char) addr[2],
+ (unsigned char) addr[3]);
+}
diff --git a/src/core/ngx_inet.h b/src/core/ngx_inet.h
new file mode 100644
index 0000000..0766d1f
--- /dev/null
+++ b/src/core/ngx_inet.h
@@ -0,0 +1,8 @@
+#ifndef _NGX_INET_H_INCLUDED_
+#define _NGX_INET_H_INCLUDED_
+
+
+size_t ngx_inet_ntop(int family, char *addr, char *text, size_t len);
+
+
+#endif /* _NGX_INET_H_INCLUDED_ */
diff --git a/src/core/ngx_string.h b/src/core/ngx_string.h
index de9b14b..ddfdacc 100644
--- a/src/core/ngx_string.h
+++ b/src/core/ngx_string.h
@@ -6,17 +6,24 @@
typedef struct {
- int len;
- char *data;
+ size_t len;
+ char *data;
} ngx_str_t;
#if (WIN32)
+
+#define ngx_memzero ZeroMemory
+
+#define strcasecmp stricmp
+
#define ngx_snprintf _snprintf
#define ngx_vsnprintf _vsnprintf
#else
+#define ngx_memzero bzero
+
#define ngx_snprintf snprintf
#define ngx_vsnprintf vsnprintf