nginx-0.0.7-2004-06-17-21:18:53 import
diff --git a/auto/feature b/auto/feature
new file mode 100644
index 0000000..32a103d
--- /dev/null
+++ b/auto/feature
@@ -0,0 +1,53 @@
+
+echo $ngx_n "checking for $ngx_feature ..." $ngx_c
+echo >> $NGX_ERR
+echo "checking for $ngx_feature" >> $NGX_ERR
+
+ngx_found=no
+
+feature=`echo $ngx_feature_name | tr '[a-z]' '[A-Z]'`
+
+cat << END > $NGX_AUTOTEST.c
+
+#include <sys/types.h>
+$NGX_UNISTD_H
+$ngx_feature_inc
+
+int main() {
+ $ngx_feature_test;
+ return 0;
+}
+
+END
+
+test="$CC_WARN $CC_TEST_FLAGS -o $NGX_AUTOTEST $NGX_AUTOTEST.c \
+ $ngx_feature_libs"
+eval "$test >> $NGX_ERR 2>&1"
+
+if [ -x $NGX_AUTOTEST ]; then
+
+ if [ $ngx_feature_run = yes ]; then
+ if $NGX_AUTOTEST 2>&1 > /dev/null; then
+ echo " found"
+ have=HAVE_$feature . auto/have
+ ngx_found=yes
+ else
+ echo " found but is not working"
+ fi
+
+ else
+ echo " found"
+ have=HAVE_$feature . auto/have
+ ngx_found=yes
+ fi
+
+else
+ echo " not found"
+ echo "---------" >> $NGX_ERR
+ cat $NGX_AUTOTEST.c >> $NGX_ERR
+ echo "---------" >> $NGX_ERR
+ echo $test >> $NGX_ERR
+ echo "---------" >> $NGX_ERR
+fi
+
+rm $NGX_AUTOTEST*
diff --git a/auto/func b/auto/func
index 3f12b78..af74331 100644
--- a/auto/func
+++ b/auto/func
@@ -5,7 +5,7 @@
ngx_found=no
-func=`echo $ngx_func | sed -e 's/()$//' | tr '[a-z.]' '[A-Z_]'`
+func=`echo $ngx_func | sed -e 's/()$//' | tr '[a-z]' '[A-Z]'`
cat << END > $NGX_AUTOTEST.c
@@ -20,8 +20,8 @@
END
-eval "$CC_WARN $CC_TEST_FLAGS -o $NGX_AUTOTEST $NGX_AUTOTEST.c $ngx_func_libs \
- >> $NGX_ERR 2>&1"
+test="$CC_WARN $CC_TEST_FLAGS -o $NGX_AUTOTEST $NGX_AUTOTEST.c $ngx_func_libs"
+eval "$test >> $NGX_ERR 2>&1"
if [ -x $NGX_AUTOTEST ]; then
echo " found"
@@ -30,6 +30,11 @@
else
echo " not found"
+ echo "---------" >> $NGX_ERR
+ cat $NGX_AUTOTEST.c >> $NGX_ERR
+ echo "---------" >> $NGX_ERR
+ echo $test >> $NGX_ERR
+ echo "---------" >> $NGX_ERR
fi
rm $NGX_AUTOTEST*
diff --git a/auto/sources b/auto/sources
index a49cca0..ba2934a 100644
--- a/auto/sources
+++ b/auto/sources
@@ -105,6 +105,7 @@
src/os/unix/ngx_errno.h \
src/os/unix/ngx_alloc.h \
src/os/unix/ngx_files.h \
+ src/os/unix/ngx_shared.h \
src/os/unix/ngx_process.h \
src/os/unix/ngx_thread.h \
src/os/unix/ngx_socket.h \
@@ -120,8 +121,9 @@
src/os/unix/ngx_recv.c \
src/os/unix/ngx_readv_chain.c \
src/os/unix/ngx_writev_chain.c \
- src/os/unix/ngx_daemon.c \
+ src/os/unix/ngx_shared.c \
src/os/unix/ngx_process.c \
+ src/os/unix/ngx_daemon.c \
src/os/unix/ngx_posix_init.c \
src/os/unix/ngx_process_cycle.c"
@@ -152,6 +154,7 @@
src/os/win32/ngx_errno.h \
src/os/win32/ngx_alloc.h \
src/os/win32/ngx_files.h \
+ src/os/win32/ngx_shared.h \
src/os/win32/ngx_process.h \
src/os/win32/ngx_socket.h \
src/os/win32/ngx_os.h \
diff --git a/auto/unix b/auto/unix
index 183a503..5cd940e 100755
--- a/auto/unix
+++ b/auto/unix
@@ -40,14 +40,6 @@
. auto/types/uintptr_t
-ngx_func="sin_len"
-ngx_func_inc="#include <sys/socket.h>
-#include <netinet/in.h>"
-
-ngx_func_test="struct sockaddr_in sa; sa.sin_len = 5"
-. auto/func
-
-
# printf() formats
CC_WARN=$CC_STRONG
@@ -71,19 +63,21 @@
eval ngx_formats=\${ngx_${ngx_bytes}_fmt}; . auto/fmt/fmt
-# syscalls and libc calls
+# syscalls, libc calls and some features
+
+ngx_feature_libs=
+ngx_func_libs=
+
ngx_func="pread()"
ngx_func_inc=
-ngx_func_test="char buf[1]; ssize_t n;
- n = pread(0, buf, 1, 0)"
+ngx_func_test="char buf[1]; ssize_t n; n = pread(0, buf, 1, 0)"
. auto/func
ngx_func="pwrite()"
ngx_func_inc=
-ngx_func_test="char buf[1]; ssize_t n;
- n = pwrite(1, buf, 1, 0)"
+ngx_func_test="char buf[1]; ssize_t n; n = pwrite(1, buf, 1, 0)"
. auto/func
@@ -113,7 +107,7 @@
ngx_func="posix_memalign()"
ngx_func_inc="#include <stdlib.h>"
-ngx_func_test="void *p, int n; n = posix_memalign(&p, 4096, 4096)"
+ngx_func_test="void *p; int n; n = posix_memalign(&p, 4096, 4096)"
. auto/func
@@ -123,13 +117,76 @@
. auto/func
-ngx_func="msghdr.msg_control"
-ngx_func_inc="#include <sys/socket.h>"
-ngx_func_test="struct msghdr msg; msg.msg_control = NULL"
-. auto/func
+
+ngx_feature="mmap(MAP_ANON|MAP_SHARED)"
+ngx_feature_name="MAP_ANON"
+ngx_feature_inc="#include <sys/mman.h>"
+ngx_feature_test="void *p;
+ p = mmap(NULL, 4096, PROT_READ|PROT_WRITE,
+ MAP_ANON|MAP_SHARED, -1, 0);
+ if (p == MAP_FAILED) return 1;"
+ngx_feature_run=yes
+. auto/feature
-ngx_func="FIONBIO"
-ngx_func_inc="#include <sys/filio.h>"
-ngx_func_test="int i; i = FIONBIO"
-. auto/func
+ngx_feature='mmap("/dev/zero", MAP_SHARED)'
+ngx_feature_name="MAP_DEVZERO"
+ngx_feature_inc="#include <sys/mman.h>
+#include <sys/stat.h>
+#include <fcntl.h>"
+ngx_feature_test='void *p; int fd;
+ fd = open("/dev/zero", O_RDWR);
+ p = mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
+ if (p == MAP_FAILED) return 1;'
+. auto/feature
+
+
+ngx_feature="System V shared memory"
+ngx_feature_name="SYSVSHM"
+ngx_feature_inc="#include <sys/ipc.h>
+#include <sys/shm.h>"
+ngx_feature_test="int id;
+ id = shmget(IPC_PRIVATE, 4096, (SHM_R|SHM_W|IPC_CREAT));
+ if (id == -1) return 1;
+ shmctl(id, IPC_RMID, NULL);"
+. auto/feature
+
+
+
+ngx_feature="struct sockaddr_in.sin_len"
+ngx_feature_name="sin_len"
+ngx_feature_inc="#include <sys/socket.h>
+#include <netinet/in.h>"
+ngx_feature_test="struct sockaddr_in sa; sa.sin_len = 5"
+ngx_feature_run=no
+. auto/feature
+
+
+ngx_feature="struct msghdr.msg_control"
+ngx_feature_name="msghdr_msg_control"
+ngx_feature_inc="#include <sys/socket.h>"
+ngx_feature_test="struct msghdr msg; msg.msg_control = NULL"
+. auto/feature
+
+
+case $PLATFORM in
+ Linux:*)
+ ngx_feature_inc="#include <sys/ioctl.h>"
+ ;;
+
+ *)
+ ngx_feature_inc="#include <sys/filio.h>"
+ ;;
+esac
+
+ngx_feature="ioctl(FIONBIO)"
+ngx_feature_name="FIONBIO"
+ngx_feature_test="int i; i = FIONBIO"
+. auto/feature
+
+
+ngx_feature="struct tm.tm_gmtoff"
+ngx_feature_name="gmtoff"
+ngx_feature_inc="#include <time.h>"
+ngx_feature_test="struct tm tm; tm.tm_gmtoff = 0"
+. auto/feature
diff --git a/src/core/ngx_core.h b/src/core/ngx_core.h
index 55c4147..2a112dd 100644
--- a/src/core/ngx_core.h
+++ b/src/core/ngx_core.h
@@ -19,6 +19,7 @@
#include <ngx_time.h>
#include <ngx_socket.h>
#include <ngx_errno.h>
+#include <ngx_shared.h>
#include <ngx_process.h>
#include <ngx_thread.h>
#include <ngx_user.h>
diff --git a/src/core/ngx_times.c b/src/core/ngx_times.c
index ac2a3a9..aa461c5 100644
--- a/src/core/ngx_times.c
+++ b/src/core/ngx_times.c
@@ -123,15 +123,20 @@
ngx_cached_http_time.data = p;
-#if (HAVE_TIMEZONE)
+#if (HAVE_GETTIMEZONE)
- ngx_gmtoff = ngx_timezone();
+ ngx_gmtoff = ngx_gettimezone();
ngx_gmtime(ngx_cached_time + ngx_gmtoff * 60, &tm);
+#elif (HAVE_GMTOFF)
+
+ ngx_localtime(&tm);
+ ngx_gmtoff = tm.ngx_tm_gmtoff / 60;
+
#else
ngx_localtime(&tm);
- ngx_gmtoff = tm.ngx_tm_gmtoff / 60;
+ ngx_gmtoff = ngx_timezone(tm.ngx_tm_isdst);
#endif
diff --git a/src/event/ngx_event.c b/src/event/ngx_event.c
index a74430a..728dbde 100644
--- a/src/event/ngx_event.c
+++ b/src/event/ngx_event.c
@@ -187,6 +187,7 @@
size = 128 /* ngx_accept_mutex */
+ 128; /* ngx_connection_counter */
+#if 0
shared = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, -1, 0);
if (shared == MAP_FAILED) {
@@ -194,6 +195,11 @@
"mmap(MAP_ANON|MAP_SHARED) failed");
return NGX_ERROR;
}
+#endif
+
+ if (!(shared = ngx_create_shared_memory(size, cycle->log))) {
+ return NGX_ERROR;
+ }
ngx_accept_mutex_ptr = (ngx_atomic_t *) shared;
ngx_connection_counter = (ngx_atomic_t *) (shared + 128);
@@ -611,7 +617,7 @@
NGX_CONF_ERROR);
ecf->connections = NGX_CONF_UNSET_UINT;
- ecf->use = NGX_CONF_UNSET;
+ ecf->use = NGX_CONF_UNSET_UINT;
ecf->multi_accept = NGX_CONF_UNSET;
ecf->accept_mutex = NGX_CONF_UNSET;
ecf->accept_mutex_delay = NGX_CONF_UNSET_MSEC;
@@ -694,9 +700,9 @@
return NGX_CONF_ERROR;
}
- ngx_conf_unsigned_init_value(ecf->connections, DEFAULT_CONNECTIONS);
+ ngx_conf_init_unsigned_value(ecf->connections, DEFAULT_CONNECTIONS);
- ngx_conf_unsigned_init_value(ecf->use, m);
+ ngx_conf_init_unsigned_value(ecf->use, m);
ngx_conf_init_ptr_value(ecf->name, module->name->data);
#endif
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index 3f50666..0f30a31 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -943,7 +943,8 @@
* in CPU cache
*/
- ua = ngx_strstr(r->headers_in.user_agent->value.data, "MSIE");
+ ua = (u_char *) ngx_strstr(r->headers_in.user_agent->value.data,
+ "MSIE");
if (ua
&& ua + 8 < r->headers_in.user_agent->value.data
+ r->headers_in.user_agent->value.len)
diff --git a/src/os/unix/ngx_linux_config.h b/src/os/unix/ngx_linux_config.h
index 2b6eb9c..8a75e22 100644
--- a/src/os/unix/ngx_linux_config.h
+++ b/src/os/unix/ngx_linux_config.h
@@ -41,11 +41,6 @@
#include <netinet/tcp.h> /* TCP_CORK */
-/* Linux has no <sys/filio.h> so autoconfigure does not find FIONBIO */
-#ifndef HAVE_FIONBIO
-#define HAVE_FIONBIO 1
-#endif
-
#include <ngx_auto_config.h>
diff --git a/src/os/unix/ngx_shared.c b/src/os/unix/ngx_shared.c
new file mode 100644
index 0000000..a19ca53
--- /dev/null
+++ b/src/os/unix/ngx_shared.c
@@ -0,0 +1,91 @@
+
+#include <ngx_config.h>
+#include <ngx_core.h>
+
+
+#if (HAVE_MAP_ANON)
+
+void *ngx_create_shared_memory(size_t size, ngx_log_t *log)
+{
+ void *p;
+
+ p = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, -1, 0);
+
+ if (p == MAP_FAILED) {
+ ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
+ "mmap(MAP_ANON|MAP_SHARED, " SIZE_T_FMT ") failed",
+ size);
+ return NULL;
+ }
+
+ return p;
+}
+
+#elif (HAVE_MAP_DEVZERO)
+
+void *ngx_create_shared_memory(size_t size, ngx_log_t *log)
+{
+ void *p;
+ ngx_fd_t fd;
+
+ fd = open("/dev/zero", O_RDWR);
+
+ if (fd == -1) {
+ ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
+ "open(/dev/zero) failed");
+ return NULL;
+ }
+
+ p = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
+
+ if (p == MAP_FAILED) {
+ ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
+ "mmap(/dev/zero, MAP_SHARED, " SIZE_T_FMT ") failed",
+ size);
+ p = NULL;
+ }
+
+ if (close(fd) == -1) {
+ ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, "close() failed");
+ }
+
+ return p;
+}
+
+#elif (HAVE_SYSVSHM)
+
+#include <sys/ipc.h>
+#include <sys/shm.h>
+
+
+void *ngx_create_shared_memory(size_t size, ngx_log_t *log)
+{
+ int id;
+ void *p;
+
+ id = shmget(IPC_PRIVATE, size, (SHM_R|SHM_W|IPC_CREAT));
+
+ if (id == -1) {
+ ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
+ "shmget(" SIZE_T_FMT ") failed", size);
+ return NULL;
+ }
+
+ ngx_log_debug1(NGX_LOG_DEBUG_CORE, log, 0, "shmget id: %d", id);
+
+ p = shmat(id, NULL, 0);
+
+ if (p == (void *) -1) {
+ ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, "shmat() failed");
+ p = NULL;
+ }
+
+ if (shmctl(id, IPC_RMID, NULL) == -1) {
+ ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, "shmctl(IPC_RMID) failed");
+ p = NULL;
+ }
+
+ return p;
+}
+
+#endif
diff --git a/src/os/unix/ngx_shared.h b/src/os/unix/ngx_shared.h
new file mode 100644
index 0000000..ca077df
--- /dev/null
+++ b/src/os/unix/ngx_shared.h
@@ -0,0 +1,12 @@
+#ifndef _NGX_SHARED_H_INCLUDED_
+#define _NGX_SHARED_H_INCLUDED_
+
+
+#include <ngx_config.h>
+#include <ngx_core.h>
+
+
+void *ngx_create_shared_memory(size_t size, ngx_log_t *log);
+
+
+#endif /* _NGX_SHARED_H_INCLUDED_ */
diff --git a/src/os/unix/ngx_time.h b/src/os/unix/ngx_time.h
index dbb7a0a..7cf3d01 100644
--- a/src/os/unix/ngx_time.h
+++ b/src/os/unix/ngx_time.h
@@ -9,7 +9,6 @@
typedef uint64_t ngx_epoch_msec_t;
typedef ngx_int_t ngx_msec_t;
-#define NGX_MAX_MSEC (ngx_msec_t) -1
typedef struct tm ngx_tm_t;
@@ -20,11 +19,7 @@
#define ngx_tm_mon tm_mon
#define ngx_tm_year tm_year
#define ngx_tm_wday tm_wday
-#define ngx_tm_gmtoff tm_gmtoff
-
-#ifndef SOLARIS
-#define ngx_tm_zone tm_zone
-#endif
+#define ngx_tm_isdst tm_isdst
#define ngx_tm_sec_t int
#define ngx_tm_min_t int
@@ -35,16 +30,14 @@
#define ngx_tm_wday_t int
+#if (HAVE_GMTOFF)
+#define ngx_tm_gmtoff tm_gmtoff
+#define ngx_tm_zone tm_zone
+#endif
+
+
#if (SOLARIS)
-#define HAVE_TIMEZONE 1
-
-#define ngx_timezone() (- (daylight ? altzone : timezone) / 60)
-
-#elif defined __linux__
-#define HAVE_TIMEZONE 1
-
-#define ngx_timezone() (- timezone / 60 + daylight * 60)
-
+#define ngx_timezone(isdst) (- (isdst ? altzone : timezone) / 60)
#endif
diff --git a/src/os/win32/ngx_shared.h b/src/os/win32/ngx_shared.h
new file mode 100644
index 0000000..ca077df
--- /dev/null
+++ b/src/os/win32/ngx_shared.h
@@ -0,0 +1,12 @@
+#ifndef _NGX_SHARED_H_INCLUDED_
+#define _NGX_SHARED_H_INCLUDED_
+
+
+#include <ngx_config.h>
+#include <ngx_core.h>
+
+
+void *ngx_create_shared_memory(size_t size, ngx_log_t *log);
+
+
+#endif /* _NGX_SHARED_H_INCLUDED_ */
diff --git a/src/os/win32/ngx_time.c b/src/os/win32/ngx_time.c
index cef3357..85d1a3b 100644
--- a/src/os/win32/ngx_time.c
+++ b/src/os/win32/ngx_time.c
@@ -31,7 +31,7 @@
}
-ngx_int_t ngx_timezone(void)
+ngx_int_t ngx_gettimezone(void)
{
TIME_ZONE_INFORMATION tz;
diff --git a/src/os/win32/ngx_time.h b/src/os/win32/ngx_time.h
index 9ed94ba..f860116 100644
--- a/src/os/win32/ngx_time.h
+++ b/src/os/win32/ngx_time.h
@@ -9,7 +9,6 @@
typedef uint64_t ngx_epoch_msec_t;
typedef ngx_int_t ngx_msec_t;
-#define NGX_MAX_MSEC (ngx_msec_t) -1
typedef SYSTEMTIME ngx_tm_t;
@@ -32,11 +31,11 @@
#define ngx_tm_wday_t u_short
-#define ngx_msleep Sleep
+#define ngx_msleep Sleep
-#define HAVE_TIMEZONE 1
+#define HAVE_GETIMEZONE 1
-ngx_int_t ngx_timezone(void);
+ngx_int_t ngx_gettimezone(void);
void ngx_gettimeofday(struct timeval *tp);