nginx-0.3.27-RELEASE import
*) Change: the "variables_hash_max_size" and
"variables_hash_bucket_size" directives.
*) Feature: the $body_bytes_sent variable can be used not only in the
"log_format" directive.
*) Feature: the $ssl_protocol and $ssl_cipher variables.
*) Feature: the cache line size detection for widespread CPUs at start
time.
*) Feature: now the "accept_mutex" directive is supported using
fcntl(2) on platforms different from i386, amd64, sparc64, and ppc.
*) Feature: the "lock_file" directive and the --with-lock-path=PATH
autoconfiguration directive.
*) Bugfix: if the HTTPS protocol was used in the "proxy_pass" directive
then the requests with the body was not transferred.
diff --git a/src/os/unix/ngx_atomic.h b/src/os/unix/ngx_atomic.h
index 50d6354..c505027 100644
--- a/src/os/unix/ngx_atomic.h
+++ b/src/os/unix/ngx_atomic.h
@@ -34,6 +34,7 @@
/* the code in src/os/unix/ngx_sunpro_x86.il */
#define ngx_memory_barrier() __asm (".volatile"); __asm (".nonvolatile")
+#define ngx_cpu_pause() __asm ("pause")
#else /* ( __GNUC__ || __INTEL_COMPILER ) */
@@ -67,6 +68,7 @@
/* the code in src/os/unix/ngx_sunpro_amd64.il */
#define ngx_memory_barrier() __asm (".volatile"); __asm (".nonvolatile")
+#define ngx_cpu_pause() __asm ("pause")
#else /* ( __GNUC__ || __INTEL_COMPILER ) */
@@ -175,10 +177,11 @@
}
#define ngx_memory_barrier()
+#define ngx_cpu_pause()
#endif
-void ngx_spinlock(ngx_atomic_t *lock, ngx_uint_t spin);
+void ngx_spinlock(ngx_atomic_t *lock, ngx_atomic_int_t value, ngx_uint_t spin);
#define ngx_trylock(lock) (*(lock) == 0 && ngx_atomic_cmp_set(lock, 0, 1))
#define ngx_unlock(lock) *(lock) = 0
diff --git a/src/os/unix/ngx_files.c b/src/os/unix/ngx_files.c
index b5a807b..f89147d 100644
--- a/src/os/unix/ngx_files.c
+++ b/src/os/unix/ngx_files.c
@@ -235,59 +235,58 @@
}
-ngx_int_t
-ngx_lock_file(ngx_file_t *file)
+ngx_err_t
+ngx_trylock_fd(ngx_fd_t fd)
{
- ngx_err_t err;
struct flock fl;
- fl.l_whence = SEEK_SET;
+ fl.l_start = 0;
fl.l_len = 0;
fl.l_pid = 0;
fl.l_type = F_WRLCK;
- fl.l_start = 0;
+ fl.l_whence = SEEK_SET;
- if (fcntl(file->fd, F_SETLK, &fl) == -1) {
- err = ngx_errno;
-
- if (err == NGX_EAGAIN) {
- return NGX_BUSY;
- }
-
- ngx_log_error(NGX_LOG_ALERT, file->log, err,
- "fcntl(%s, F_SETLK, F_WRLCK) failed", file->name.data);
-
- return NGX_ERROR;
+ if (fcntl(fd, F_SETLK, &fl) == -1) {
+ return ngx_errno;
}
- return NGX_OK;
+ return 0;
}
-ngx_int_t
-ngx_unlock_file(ngx_file_t *file)
+ngx_err_t
+ngx_lock_fd(ngx_fd_t fd)
{
- ngx_err_t err;
struct flock fl;
+ fl.l_start = 0;
+ fl.l_len = 0;
+ fl.l_pid = 0;
+ fl.l_type = F_WRLCK;
fl.l_whence = SEEK_SET;
+
+ if (fcntl(fd, F_SETLKW, &fl) == -1) {
+ return ngx_errno;
+ }
+
+ return 0;
+}
+
+
+ngx_err_t
+ngx_unlock_fd(ngx_fd_t fd)
+{
+ struct flock fl;
+
+ fl.l_start = 0;
fl.l_len = 0;
fl.l_pid = 0;
fl.l_type = F_UNLCK;
- fl.l_start = 0;
+ fl.l_whence = SEEK_SET;
- if (fcntl(file->fd, F_SETLK, &fl) == -1) {
- err = ngx_errno;
-
- if (err == NGX_EAGAIN) {
- return NGX_BUSY;
- }
-
- ngx_log_error(NGX_LOG_ALERT, file->log, err,
- "fcntl(%s, F_SETLK, F_UNLCK) failed", file->name.data);
-
- return NGX_ERROR;
+ if (fcntl(fd, F_SETLK, &fl) == -1) {
+ return ngx_errno;
}
- return NGX_OK;
+ return 0;
}
diff --git a/src/os/unix/ngx_files.h b/src/os/unix/ngx_files.h
index a361fe4..fcf5da4 100644
--- a/src/os/unix/ngx_files.h
+++ b/src/os/unix/ngx_files.h
@@ -119,4 +119,13 @@
#define ngx_de_mtime(dir) (dir)->info.st_mtime
+ngx_err_t ngx_trylock_fd(ngx_fd_t fd);
+ngx_err_t ngx_lock_fd(ngx_fd_t fd);
+ngx_err_t ngx_unlock_fd(ngx_fd_t fd);
+
+#define ngx_trylock_fd_n "fcntl(F_SETLK, F_WRLCK)"
+#define ngx_lock_fd_n "fcntl(F_SETLKW, F_WRLCK)"
+#define ngx_unlock_fd_n "fcntl(F_SETLK, F_UNLCK)"
+
+
#endif /* _NGX_FILES_H_INCLUDED_ */
diff --git a/src/os/unix/ngx_gcc_atomic_amd64.h b/src/os/unix/ngx_gcc_atomic_amd64.h
index 2183e73..289cd61 100644
--- a/src/os/unix/ngx_gcc_atomic_amd64.h
+++ b/src/os/unix/ngx_gcc_atomic_amd64.h
@@ -74,4 +74,6 @@
}
-#define ngx_memory_barrier() __asm__ volatile ("" ::: "memory")
+#define ngx_memory_barrier() __asm__ volatile ("" ::: "memory")
+
+#define ngx_cpu_pause() __asm__ ("pause")
diff --git a/src/os/unix/ngx_gcc_atomic_ppc.h b/src/os/unix/ngx_gcc_atomic_ppc.h
index a6bbb39..5339ba9 100644
--- a/src/os/unix/ngx_gcc_atomic_ppc.h
+++ b/src/os/unix/ngx_gcc_atomic_ppc.h
@@ -71,3 +71,5 @@
#else
#define ngx_memory_barrier() __asm__ volatile ("" ::: "memory")
#endif
+
+#define ngx_cpu_pause()
diff --git a/src/os/unix/ngx_gcc_atomic_sparc64.h b/src/os/unix/ngx_gcc_atomic_sparc64.h
index fc6bace..e5a6254 100644
--- a/src/os/unix/ngx_gcc_atomic_sparc64.h
+++ b/src/os/unix/ngx_gcc_atomic_sparc64.h
@@ -77,3 +77,5 @@
#else
#define ngx_memory_barrier() __asm__ volatile ("" ::: "memory")
#endif
+
+#define ngx_cpu_pause()
diff --git a/src/os/unix/ngx_gcc_atomic_x86.h b/src/os/unix/ngx_gcc_atomic_x86.h
index 8e3480d..1e15825 100644
--- a/src/os/unix/ngx_gcc_atomic_x86.h
+++ b/src/os/unix/ngx_gcc_atomic_x86.h
@@ -118,3 +118,6 @@
*/
#define ngx_memory_barrier() __asm__ volatile ("" ::: "memory")
+
+/* old as does not support "pause" opcode */
+#define ngx_cpu_pause() __asm__ (".byte 0xf3, 0x90")
diff --git a/src/os/unix/ngx_posix_init.c b/src/os/unix/ngx_posix_init.c
index 83d5f30..a44a89c 100644
--- a/src/os/unix/ngx_posix_init.c
+++ b/src/os/unix/ngx_posix_init.c
@@ -45,6 +45,8 @@
ngx_ncpu = 1;
}
+ ngx_cpuinfo();
+
if (getrlimit(RLIMIT_NOFILE, &rlmt) == -1) {
ngx_log_error(NGX_LOG_ALERT, log, errno,
"getrlimit(RLIMIT_NOFILE) failed)");
diff --git a/src/os/unix/ngx_sunpro_atomic_sparc64.h b/src/os/unix/ngx_sunpro_atomic_sparc64.h
index 691e94e..db85211 100644
--- a/src/os/unix/ngx_sunpro_atomic_sparc64.h
+++ b/src/os/unix/ngx_sunpro_atomic_sparc64.h
@@ -56,3 +56,5 @@
__asm (".volatile"); \
__asm ("membar #LoadLoad | #LoadStore | #StoreStore | #StoreLoad"); \
__asm (".nonvolatile")
+
+#define ngx_cpu_pause()
diff --git a/src/os/win32/ngx_atomic.h b/src/os/win32/ngx_atomic.h
index 8003b74..5e32f1f 100644
--- a/src/os/win32/ngx_atomic.h
+++ b/src/os/win32/ngx_atomic.h
@@ -45,7 +45,14 @@
#define ngx_memory_barrier()
-void ngx_spinlock(ngx_atomic_t *lock, ngx_uint_t spin);
+#ifdef __BORLANDC__
+#define ngx_cpu_pause()
+#else
+#define ngx_cpu_pause() __asm { pause }
+#endif
+
+
+void ngx_spinlock(ngx_atomic_t *lock, ngx_atomic_int_t value, ngx_uint_t spin);
#define ngx_trylock(lock) (*(lock) == 0 && ngx_atomic_cmp_set(lock, 0, 1))
#define ngx_unlock(lock) *(lock) = 0