Mercurial > hg > nginx-quic
annotate src/os/unix/ngx_thread_mutex.c @ 6591:04d8d1f85649
SSL: ngx_ssl_ciphers() to set list of ciphers.
This patch moves various OpenSSL-specific function calls into the
OpenSSL module and introduces ngx_ssl_ciphers() to make nginx more
crypto-library-agnostic.
author | Tim Taubert <tim@timtaubert.de> |
---|---|
date | Wed, 15 Jun 2016 21:05:30 +0100 |
parents | e511e3d581bb |
children | 022ea0d17177 |
rev | line source |
---|---|
6018
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
1 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
2 /* |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
4 * Copyright (C) Nginx, Inc. |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
5 */ |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
6 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
7 #include <ngx_config.h> |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
8 #include <ngx_core.h> |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
9 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
10 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
11 /* |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
12 * All modern pthread mutex implementations try to acquire a lock |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
13 * atomically in userland before going to sleep in kernel. Some |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
14 * spins before the sleeping. |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
15 * |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
16 * In Solaris since version 8 all mutex types spin before sleeping. |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
17 * The default spin count is 1000. It can be overridden using |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
18 * _THREAD_ADAPTIVE_SPIN=100 environment variable. |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
19 * |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
20 * In MacOSX all mutex types spin to acquire a lock protecting a mutex's |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
21 * internals. If the mutex is busy, thread calls Mach semaphore_wait(). |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
22 * |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
23 * |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
24 * PTHREAD_MUTEX_NORMAL lacks deadlock detection and is the fastest |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
25 * mutex type. |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
26 * |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
27 * Linux: No spinning. The internal name PTHREAD_MUTEX_TIMED_NP |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
28 * remains from the times when pthread_mutex_timedlock() was |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
29 * non-standard extension. Alias name: PTHREAD_MUTEX_FAST_NP. |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
30 * FreeBSD: No spinning. |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
31 * |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
32 * |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
33 * PTHREAD_MUTEX_ERRORCHECK is usually as fast as PTHREAD_MUTEX_NORMAL |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
34 * yet has lightweight deadlock detection. |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
35 * |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
36 * Linux: No spinning. The internal name: PTHREAD_MUTEX_ERRORCHECK_NP. |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
37 * FreeBSD: No spinning. |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
38 * |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
39 * |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
40 * PTHREAD_MUTEX_RECURSIVE allows recursive locking. |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
41 * |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
42 * Linux: No spinning. The internal name: PTHREAD_MUTEX_RECURSIVE_NP. |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
43 * FreeBSD: No spinning. |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
44 * |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
45 * |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
46 * PTHREAD_MUTEX_ADAPTIVE_NP spins on SMP systems before sleeping. |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
47 * |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
48 * Linux: No deadlock detection. Dynamically changes a spin count |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
49 * for each mutex from 10 to 100 based on spin count taken |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
50 * previously. |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
51 * FreeBSD: Deadlock detection. The default spin count is 2000. |
6585 | 52 * It can be overridden using LIBPTHREAD_SPINLOOPS environment |
6018
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
53 * variable or by pthread_mutex_setspinloops_np(). If a lock |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
54 * is still busy, sched_yield() can be called on both UP and |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
55 * SMP systems. The default yield loop count is zero, but |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
56 * it can be set by LIBPTHREAD_YIELDLOOPS environment |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
57 * variable or by pthread_mutex_setyieldloops_np(). |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
58 * Solaris: No PTHREAD_MUTEX_ADAPTIVE_NP. |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
59 * MacOSX: No PTHREAD_MUTEX_ADAPTIVE_NP. |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
60 * |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
61 * |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
62 * PTHREAD_MUTEX_ELISION_NP is a Linux extension to elide locks using |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
63 * Intel Restricted Transactional Memory. It is the most suitable for |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
64 * rwlock pattern access because it allows simultaneous reads without lock. |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
65 * Supported since glibc 2.18. |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
66 * |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
67 * |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
68 * PTHREAD_MUTEX_DEFAULT is default mutex type. |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
69 * |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
70 * Linux: PTHREAD_MUTEX_NORMAL. |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
71 * FreeBSD: PTHREAD_MUTEX_ERRORCHECK. |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
72 * Solaris: PTHREAD_MUTEX_NORMAL. |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
73 * MacOSX: PTHREAD_MUTEX_NORMAL. |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
74 */ |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
75 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
76 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
77 ngx_int_t |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
78 ngx_thread_mutex_create(ngx_thread_mutex_t *mtx, ngx_log_t *log) |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
79 { |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
80 ngx_err_t err; |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
81 pthread_mutexattr_t attr; |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
82 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
83 err = pthread_mutexattr_init(&attr); |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
84 if (err != 0) { |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
85 ngx_log_error(NGX_LOG_EMERG, log, err, |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
86 "pthread_mutexattr_init() failed"); |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
87 return NGX_ERROR; |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
88 } |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
89 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
90 err = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK); |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
91 if (err != 0) { |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
92 ngx_log_error(NGX_LOG_EMERG, log, err, |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
93 "pthread_mutexattr_settype" |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
94 "(PTHREAD_MUTEX_ERRORCHECK) failed"); |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
95 return NGX_ERROR; |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
96 } |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
97 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
98 err = pthread_mutex_init(mtx, &attr); |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
99 if (err != 0) { |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
100 ngx_log_error(NGX_LOG_EMERG, log, err, |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
101 "pthread_mutex_init() failed"); |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
102 return NGX_ERROR; |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
103 } |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
104 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
105 err = pthread_mutexattr_destroy(&attr); |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
106 if (err != 0) { |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
107 ngx_log_error(NGX_LOG_ALERT, log, err, |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
108 "pthread_mutexattr_destroy() failed"); |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
109 } |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
110 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
111 ngx_log_debug1(NGX_LOG_DEBUG_CORE, log, 0, |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
112 "pthread_mutex_init(%p)", mtx); |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
113 return NGX_OK; |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
114 } |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
115 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
116 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
117 ngx_int_t |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
118 ngx_thread_mutex_destroy(ngx_thread_mutex_t *mtx, ngx_log_t *log) |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
119 { |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
120 ngx_err_t err; |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
121 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
122 err = pthread_mutex_destroy(mtx); |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
123 if (err != 0) { |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
124 ngx_log_error(NGX_LOG_ALERT, log, err, |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
125 "pthread_mutex_destroy() failed"); |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
126 return NGX_ERROR; |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
127 } |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
128 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
129 ngx_log_debug1(NGX_LOG_DEBUG_CORE, log, 0, |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
130 "pthread_mutex_destroy(%p)", mtx); |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
131 return NGX_OK; |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
132 } |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
133 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
134 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
135 ngx_int_t |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
136 ngx_thread_mutex_lock(ngx_thread_mutex_t *mtx, ngx_log_t *log) |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
137 { |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
138 ngx_err_t err; |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
139 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
140 ngx_log_debug1(NGX_LOG_DEBUG_CORE, log, 0, |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
141 "pthread_mutex_lock(%p) enter", mtx); |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
142 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
143 err = pthread_mutex_lock(mtx); |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
144 if (err == 0) { |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
145 return NGX_OK; |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
146 } |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
147 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
148 ngx_log_error(NGX_LOG_ALERT, log, err, "pthread_mutex_lock() failed"); |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
149 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
150 return NGX_ERROR; |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
151 } |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
152 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
153 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
154 ngx_int_t |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
155 ngx_thread_mutex_unlock(ngx_thread_mutex_t *mtx, ngx_log_t *log) |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
156 { |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
157 ngx_err_t err; |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
158 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
159 err = pthread_mutex_unlock(mtx); |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
160 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
161 #if 0 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
162 ngx_time_update(); |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
163 #endif |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
164 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
165 if (err == 0) { |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
166 ngx_log_debug1(NGX_LOG_DEBUG_CORE, log, 0, |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
167 "pthread_mutex_unlock(%p) exit", mtx); |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
168 return NGX_OK; |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
169 } |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
170 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
171 ngx_log_error(NGX_LOG_ALERT, log, err, "pthread_mutex_unlock() failed"); |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
172 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
173 return NGX_ERROR; |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff
changeset
|
174 } |