Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nginx/nginx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/os/unix
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2006-02-08 18:33:12 +0300
committerIgor Sysoev <igor@sysoev.ru>2006-02-08 18:33:12 +0300
commitffe714403d604b385c89daa7fe5a83860a672a54 (patch)
tree24ce46a2354a79212f91fdbc3d6045ea340c3f12 /src/os/unix
parent2446d5d6adf67d81883024ffb20ec21d146c0450 (diff)
nginx-0.3.27-RELEASE importrelease-0.3.27
*) 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.
Diffstat (limited to 'src/os/unix')
-rw-r--r--src/os/unix/ngx_atomic.h5
-rw-r--r--src/os/unix/ngx_files.c61
-rw-r--r--src/os/unix/ngx_files.h9
-rw-r--r--src/os/unix/ngx_gcc_atomic_amd64.h4
-rw-r--r--src/os/unix/ngx_gcc_atomic_ppc.h2
-rw-r--r--src/os/unix/ngx_gcc_atomic_sparc64.h2
-rw-r--r--src/os/unix/ngx_gcc_atomic_x86.h3
-rw-r--r--src/os/unix/ngx_posix_init.c2
-rw-r--r--src/os/unix/ngx_sunpro_atomic_sparc64.h2
9 files changed, 57 insertions, 33 deletions
diff --git a/src/os/unix/ngx_atomic.h b/src/os/unix/ngx_atomic.h
index 50d6354d5..c505027fd 100644
--- a/src/os/unix/ngx_atomic.h
+++ b/src/os/unix/ngx_atomic.h
@@ -34,6 +34,7 @@ ngx_atomic_fetch_add(ngx_atomic_t *value, ngx_atomic_int_t add);
/* 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 @@ ngx_atomic_fetch_add(ngx_atomic_t *value, ngx_atomic_int_t add);
/* 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 @@ ngx_atomic_fetch_add(ngx_atomic_t *value, ngx_atomic_int_t add)
}
#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 b5a807bb6..f89147df1 100644
--- a/src/os/unix/ngx_files.c
+++ b/src/os/unix/ngx_files.c
@@ -235,59 +235,58 @@ ngx_open_dir(ngx_str_t *name, ngx_dir_t *dir)
}
-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 (fcntl(fd, F_SETLK, &fl) == -1) {
+ return ngx_errno;
+ }
- if (err == NGX_EAGAIN) {
- return NGX_BUSY;
- }
+ return 0;
+}
- ngx_log_error(NGX_LOG_ALERT, file->log, err,
- "fcntl(%s, F_SETLK, F_WRLCK) failed", file->name.data);
- return NGX_ERROR;
+ngx_err_t
+ngx_lock_fd(ngx_fd_t fd)
+{
+ 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 NGX_OK;
+ return 0;
}
-ngx_int_t
-ngx_unlock_file(ngx_file_t *file)
+ngx_err_t
+ngx_unlock_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_UNLCK;
- fl.l_start = 0;
-
- 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);
+ fl.l_whence = SEEK_SET;
- 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 a361fe4cd..fcf5da4ad 100644
--- a/src/os/unix/ngx_files.h
+++ b/src/os/unix/ngx_files.h
@@ -119,4 +119,13 @@ ngx_int_t ngx_open_dir(ngx_str_t *name, ngx_dir_t *dir);
#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 2183e738e..289cd614e 100644
--- a/src/os/unix/ngx_gcc_atomic_amd64.h
+++ b/src/os/unix/ngx_gcc_atomic_amd64.h
@@ -74,4 +74,6 @@ ngx_atomic_fetch_add(ngx_atomic_t *value, ngx_atomic_int_t add)
}
-#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 a6bbb39d1..5339ba98c 100644
--- a/src/os/unix/ngx_gcc_atomic_ppc.h
+++ b/src/os/unix/ngx_gcc_atomic_ppc.h
@@ -71,3 +71,5 @@ ngx_atomic_fetch_add(ngx_atomic_t *value, ngx_atomic_int_t add)
#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 fc6bacee2..e5a6254ec 100644
--- a/src/os/unix/ngx_gcc_atomic_sparc64.h
+++ b/src/os/unix/ngx_gcc_atomic_sparc64.h
@@ -77,3 +77,5 @@ ngx_atomic_fetch_add(ngx_atomic_t *value, ngx_atomic_int_t add)
#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 8e3480d71..1e1582580 100644
--- a/src/os/unix/ngx_gcc_atomic_x86.h
+++ b/src/os/unix/ngx_gcc_atomic_x86.h
@@ -118,3 +118,6 @@ ngx_atomic_fetch_add(ngx_atomic_t *value, ngx_atomic_int_t add)
*/
#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 83d5f3024..a44a89cb8 100644
--- a/src/os/unix/ngx_posix_init.c
+++ b/src/os/unix/ngx_posix_init.c
@@ -45,6 +45,8 @@ ngx_os_init(ngx_log_t *log)
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 691e94ee5..db852114b 100644
--- a/src/os/unix/ngx_sunpro_atomic_sparc64.h
+++ b/src/os/unix/ngx_sunpro_atomic_sparc64.h
@@ -56,3 +56,5 @@ ngx_atomic_fetch_add(ngx_atomic_t *value, ngx_atomic_int_t add)
__asm (".volatile"); \
__asm ("membar #LoadLoad | #LoadStore | #StoreStore | #StoreLoad"); \
__asm (".nonvolatile")
+
+#define ngx_cpu_pause()