diff options
author | Igor Sysoev <igor@sysoev.ru> | 2003-04-28 15:06:39 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2003-04-28 15:06:39 +0000 |
commit | 1d8d9eee942ab1d2565048e00d1817147c49f48c (patch) | |
tree | 05b00d2609f9a7264f2356b559353b466d1be0d4 /src/os | |
parent | a09f08dbab9f06b81c1224a32607b26292015c8b (diff) | |
download | nginx-1d8d9eee942ab1d2565048e00d1817147c49f48c.tar.gz nginx-1d8d9eee942ab1d2565048e00d1817147c49f48c.zip |
nginx-0.0.1-2003-04-28-19:06:39 import
Diffstat (limited to 'src/os')
-rw-r--r-- | src/os/unix/freebsd/ngx_rfork_thread.h | 1 | ||||
-rw-r--r-- | src/os/unix/ngx_recv_chain.c | 12 | ||||
-rw-r--r-- | src/os/unix/ngx_x86_mutex.h | 30 |
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)); +} |