aboutsummaryrefslogtreecommitdiff
path: root/src/os/unix
diff options
context:
space:
mode:
Diffstat (limited to 'src/os/unix')
-rw-r--r--src/os/unix/freebsd/ngx_rfork_thread.h1
-rw-r--r--src/os/unix/ngx_recv_chain.c12
-rw-r--r--src/os/unix/ngx_x86_mutex.h30
3 files changed, 37 insertions, 6 deletions
diff --git a/src/os/unix/freebsd/ngx_rfork_thread.h b/src/os/unix/freebsd/ngx_rfork_thread.h
index bd500e1a4..2ab114e75 100644
--- a/src/os/unix/freebsd/ngx_rfork_thread.h
+++ b/src/os/unix/freebsd/ngx_rfork_thread.h
@@ -16,6 +16,7 @@ static inline ngx_tid_t ngx_gettid()
char *sp;
__asm__ ("mov %%esp,%0" : "=r" (sp));
+
return (sp > ngx_stacks_end) ? 0:
(sp - ngx_stacks_start) / ngx_stack_size + 1;
}
diff --git a/src/os/unix/ngx_recv_chain.c b/src/os/unix/ngx_recv_chain.c
index de3de73dc..7a8a3b82c 100644
--- a/src/os/unix/ngx_recv_chain.c
+++ b/src/os/unix/ngx_recv_chain.c
@@ -6,20 +6,20 @@
#include <ngx_connection.h>
-ssize_t ngx_recv_chain(ngx_connection_t *c, ngx_chain_t *ce)
+ssize_t ngx_recv_chain(ngx_connection_t *c, ngx_chain_t *entry)
{
- ssize_t n;
+ ssize_t n;
struct iovec *iov;
ngx_err_t err;
ngx_array_t io;
ngx_init_array(io, c->pool, 10, sizeof(struct iovec), NGX_ERROR);
- while (ce) {
+ while (entry) {
ngx_test_null(iov, ngx_push_array(&io), NGX_ERROR);
- iov->iov_base = ce->hunk->pos;
- iov->iov_len = ce->hunk->end - ce->hunk->last;
- ce = ce->next;
+ iov->iov_base = entry->hunk->pos;
+ iov->iov_len = entry->hunk->end - entry->hunk->last;
+ entry = entry->next;
}
ngx_log_debug(c->log, "recv: %d:%d" _ io.nelts _ iov->iov_len);
diff --git a/src/os/unix/ngx_x86_mutex.h b/src/os/unix/ngx_x86_mutex.h
new file mode 100644
index 000000000..a8ed2eee2
--- /dev/null
+++ b/src/os/unix/ngx_x86_mutex.h
@@ -0,0 +1,30 @@
+
+
+typedef struct {
+ int lock;
+} ngx_mutex_t;
+
+
+static inline int ngx_spin_lock(ngx_mutex_t *m, int count)
+{
+ int lock;
+
+ __asm__ __volatile("
+
+get_lock:
+ mov $1, %1
+ xchg %1, %2
+ cmp $0, %1
+ jne spin_lock
+
+spin_lock:
+ cmp $0, %3
+ je failed
+
+ dec %3
+ rep nop
+ cmp $0, %2
+ jne spin_lock
+
+ ": "=q" (lock), "m" (m->lock), "q" (count));
+}