mirror of
https://github.com/nginx/nginx.git
synced 2025-06-07 17:52:38 +08:00
nginx-0.0.2-2004-03-03-19:14:15 import
This commit is contained in:
parent
ea17edc917
commit
5edf387f19
@ -126,131 +126,86 @@ void ngx_assert_core(ngx_log_t *log, const char *fmt, ...);
|
|||||||
|
|
||||||
/*********************************/
|
/*********************************/
|
||||||
|
|
||||||
|
#if (NGX_DEBUG)
|
||||||
|
|
||||||
#if (HAVE_VARIADIC_MACROS)
|
#if (HAVE_VARIADIC_MACROS)
|
||||||
|
|
||||||
#if (NGX_DEBUG)
|
|
||||||
#define ngx_log_debug0(level, log, err, fmt) \
|
#define ngx_log_debug0(level, log, err, fmt) \
|
||||||
if (log->log_level & level) \
|
if (log->log_level & level) \
|
||||||
ngx_log_error_core(NGX_LOG_DEBUG, log, err, fmt)
|
ngx_log_error_core(NGX_LOG_DEBUG, log, err, fmt)
|
||||||
#else
|
|
||||||
#define ngx_log_debug0(level, log, err, fmt)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (NGX_DEBUG)
|
|
||||||
#define ngx_log_debug1(level, log, err, fmt, arg1) \
|
#define ngx_log_debug1(level, log, err, fmt, arg1) \
|
||||||
if (log->log_level & level) \
|
if (log->log_level & level) \
|
||||||
ngx_log_error_core(NGX_LOG_DEBUG, log, err, fmt, arg1)
|
ngx_log_error_core(NGX_LOG_DEBUG, log, err, fmt, arg1)
|
||||||
#else
|
|
||||||
#define ngx_log_debug1(level, log, err, fmt, arg1)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (NGX_DEBUG)
|
|
||||||
#define ngx_log_debug2(level, log, err, fmt, arg1, arg2) \
|
#define ngx_log_debug2(level, log, err, fmt, arg1, arg2) \
|
||||||
if (log->log_level & level) \
|
if (log->log_level & level) \
|
||||||
ngx_log_error_core(NGX_LOG_DEBUG, log, err, fmt, arg1, arg2)
|
ngx_log_error_core(NGX_LOG_DEBUG, log, err, fmt, arg1, arg2)
|
||||||
#else
|
|
||||||
#define ngx_log_debug2(level, log, err, fmt, arg1, arg2)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (NGX_DEBUG)
|
|
||||||
#define ngx_log_debug3(level, log, err, fmt, arg1, arg2, arg3) \
|
#define ngx_log_debug3(level, log, err, fmt, arg1, arg2, arg3) \
|
||||||
if (log->log_level & level) \
|
if (log->log_level & level) \
|
||||||
ngx_log_error_core(NGX_LOG_DEBUG, log, err, fmt, arg1, arg2, arg3)
|
ngx_log_error_core(NGX_LOG_DEBUG, log, err, fmt, arg1, arg2, arg3)
|
||||||
#else
|
|
||||||
#define ngx_log_debug3(level, log, err, fmt, arg1, arg2, arg3)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (NGX_DEBUG)
|
|
||||||
#define ngx_log_debug4(level, log, err, fmt, arg1, arg2, arg3, arg4) \
|
#define ngx_log_debug4(level, log, err, fmt, arg1, arg2, arg3, arg4) \
|
||||||
if (log->log_level & level) \
|
if (log->log_level & level) \
|
||||||
ngx_log_error_core(NGX_LOG_DEBUG, log, err, fmt, arg1, arg2, arg3, arg4)
|
ngx_log_error_core(NGX_LOG_DEBUG, log, err, fmt, arg1, arg2, arg3, arg4)
|
||||||
#else
|
|
||||||
#define ngx_log_debug4(level, log, err, fmt, arg1, arg2, arg3, arg4)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (NGX_DEBUG)
|
|
||||||
#define ngx_log_debug5(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5) \
|
#define ngx_log_debug5(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5) \
|
||||||
if (log->log_level & level) \
|
if (log->log_level & level) \
|
||||||
ngx_log_error_core(NGX_LOG_DEBUG, log, err, fmt, \
|
ngx_log_error_core(NGX_LOG_DEBUG, log, err, fmt, \
|
||||||
arg1, arg2, arg3, arg4, arg5)
|
arg1, arg2, arg3, arg4, arg5)
|
||||||
#else
|
|
||||||
#define ngx_log_debug5(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (NGX_DEBUG)
|
|
||||||
#define ngx_log_debug6(level, log, err, fmt, \
|
#define ngx_log_debug6(level, log, err, fmt, \
|
||||||
arg1, arg2, arg3, arg4, arg5, arg6) \
|
arg1, arg2, arg3, arg4, arg5, arg6) \
|
||||||
if (log->log_level & level) \
|
if (log->log_level & level) \
|
||||||
ngx_log_error_core(NGX_LOG_DEBUG, log, err, fmt, \
|
ngx_log_error_core(NGX_LOG_DEBUG, log, err, fmt, \
|
||||||
arg1, arg2, arg3, arg4, arg5, arg6)
|
arg1, arg2, arg3, arg4, arg5, arg6)
|
||||||
#else
|
|
||||||
#define ngx_log_debug6(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5, arg6)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*********************************/
|
|
||||||
|
|
||||||
#else /* NO VARIADIC MACROS */
|
#else /* NO VARIADIC MACROS */
|
||||||
|
|
||||||
#if (NGX_DEBUG)
|
|
||||||
#define ngx_log_debug0(level, log, err, fmt) \
|
#define ngx_log_debug0(level, log, err, fmt) \
|
||||||
if (log->log_level & level) \
|
if (log->log_level & level) \
|
||||||
ngx_log_debug_core(log, err, fmt)
|
ngx_log_debug_core(log, err, fmt)
|
||||||
#else
|
|
||||||
#define ngx_log_debug0(level, log, err, fmt)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (NGX_DEBUG)
|
|
||||||
#define ngx_log_debug1(level, log, err, fmt, arg1) \
|
#define ngx_log_debug1(level, log, err, fmt, arg1) \
|
||||||
if (log->log_level & level) \
|
if (log->log_level & level) \
|
||||||
ngx_log_debug_core(log, err, fmt, arg1)
|
ngx_log_debug_core(log, err, fmt, arg1)
|
||||||
#else
|
|
||||||
#define ngx_log_debug1(level, log, err, fmt, arg1)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (NGX_DEBUG)
|
|
||||||
#define ngx_log_debug2(level, log, err, fmt, arg1, arg2) \
|
#define ngx_log_debug2(level, log, err, fmt, arg1, arg2) \
|
||||||
if (log->log_level & level) \
|
if (log->log_level & level) \
|
||||||
ngx_log_debug_core(log, err, fmt, arg1, arg2)
|
ngx_log_debug_core(log, err, fmt, arg1, arg2)
|
||||||
#else
|
|
||||||
#define ngx_log_debug2(level, log, err, fmt, arg1, arg2)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (NGX_DEBUG)
|
|
||||||
#define ngx_log_debug3(level, log, err, fmt, arg1, arg2, arg3) \
|
#define ngx_log_debug3(level, log, err, fmt, arg1, arg2, arg3) \
|
||||||
if (log->log_level & level) \
|
if (log->log_level & level) \
|
||||||
ngx_log_debug_core(log, err, fmt, arg1, arg2, arg3)
|
ngx_log_debug_core(log, err, fmt, arg1, arg2, arg3)
|
||||||
#else
|
|
||||||
#define ngx_log_debug3(level, log, err, fmt, arg1, arg2, arg3)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (NGX_DEBUG)
|
|
||||||
#define ngx_log_debug4(level, log, err, fmt, arg1, arg2, arg3, arg4) \
|
#define ngx_log_debug4(level, log, err, fmt, arg1, arg2, arg3, arg4) \
|
||||||
if (log->log_level & level) \
|
if (log->log_level & level) \
|
||||||
ngx_log_debug_core(log, err, fmt, arg1, arg2, arg3, arg4)
|
ngx_log_debug_core(log, err, fmt, arg1, arg2, arg3, arg4)
|
||||||
#else
|
|
||||||
#define ngx_log_debug4(level, log, err, fmt, arg1, arg2, arg3, arg4)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (NGX_DEBUG)
|
|
||||||
#define ngx_log_debug5(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5) \
|
#define ngx_log_debug5(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5) \
|
||||||
if (log->log_level & level) \
|
if (log->log_level & level) \
|
||||||
ngx_log_debug_core(log, err, fmt, arg1, arg2, arg3, arg4, arg5)
|
ngx_log_debug_core(log, err, fmt, arg1, arg2, arg3, arg4, arg5)
|
||||||
#else
|
|
||||||
#define ngx_log_debug5(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (NGX_DEBUG)
|
|
||||||
#define ngx_log_debug6(level, log, err, fmt, \
|
#define ngx_log_debug6(level, log, err, fmt, \
|
||||||
arg1, arg2, arg3, arg4, arg5, arg6) \
|
arg1, arg2, arg3, arg4, arg5, arg6) \
|
||||||
if (log->log_level & level) \
|
if (log->log_level & level) \
|
||||||
ngx_log_debug_core(log, err, fmt, arg1, arg2, arg3, arg4, arg5, arg6)
|
ngx_log_debug_core(log, err, fmt, arg1, arg2, arg3, arg4, arg5, arg6)
|
||||||
#else
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#else /* NO NGX_DEBUG */
|
||||||
|
|
||||||
|
#define ngx_log_debug0(level, log, err, fmt)
|
||||||
|
#define ngx_log_debug1(level, log, err, fmt, arg1)
|
||||||
|
#define ngx_log_debug2(level, log, err, fmt, arg1, arg2)
|
||||||
|
#define ngx_log_debug3(level, log, err, fmt, arg1, arg2, arg3)
|
||||||
|
#define ngx_log_debug4(level, log, err, fmt, arg1, arg2, arg3, arg4)
|
||||||
|
#define ngx_log_debug5(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5)
|
||||||
#define ngx_log_debug6(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5, arg6)
|
#define ngx_log_debug6(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5, arg6)
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*********************************/
|
/*********************************/
|
||||||
|
|
||||||
#define ngx_log_alloc_log(pool, log) ngx_palloc(pool, log, sizeof(ngx_log_t))
|
#define ngx_log_alloc_log(pool, log) ngx_palloc(pool, log, sizeof(ngx_log_t))
|
||||||
|
@ -3,12 +3,6 @@
|
|||||||
#include <ngx_core.h>
|
#include <ngx_core.h>
|
||||||
#include <ngx_event.h>
|
#include <ngx_event.h>
|
||||||
|
|
||||||
/*
|
|
||||||
* TODO: eliminate mutex and use atomic_xchg():
|
|
||||||
* ev->next = ev; ngx_atomic_xchg(ngx_posted_events, ev->next);
|
|
||||||
* in ngx_event_busy_unlock() and ngx_event_busy_lock_handler()
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
static int ngx_event_busy_lock_look_cachable(ngx_event_busy_lock_t *bl,
|
static int ngx_event_busy_lock_look_cachable(ngx_event_busy_lock_t *bl,
|
||||||
ngx_event_busy_lock_ctx_t *ctx);
|
ngx_event_busy_lock_ctx_t *ctx);
|
||||||
@ -28,11 +22,9 @@ ngx_int_t ngx_event_busy_lock(ngx_event_busy_lock_t *bl,
|
|||||||
{
|
{
|
||||||
ngx_int_t rc;
|
ngx_int_t rc;
|
||||||
|
|
||||||
#if (NGX_THREADS)
|
|
||||||
if (ngx_mutex_lock(bl->mutex) == NGX_ERROR) {
|
if (ngx_mutex_lock(bl->mutex) == NGX_ERROR) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ctx->event->log, 0,
|
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ctx->event->log, 0,
|
||||||
"event busy lock: b:%d mb:%d",
|
"event busy lock: b:%d mb:%d",
|
||||||
@ -60,9 +52,7 @@ ngx_int_t ngx_event_busy_lock(ngx_event_busy_lock_t *bl,
|
|||||||
rc = NGX_BUSY;
|
rc = NGX_BUSY;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (NGX_THREADS)
|
|
||||||
ngx_mutex_unlock(bl->mutex);
|
ngx_mutex_unlock(bl->mutex);
|
||||||
#endif
|
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@ -73,11 +63,9 @@ ngx_int_t ngx_event_busy_lock_cachable(ngx_event_busy_lock_t *bl,
|
|||||||
{
|
{
|
||||||
ngx_int_t rc;
|
ngx_int_t rc;
|
||||||
|
|
||||||
#if (NGX_THREADS)
|
|
||||||
if (ngx_mutex_lock(bl->mutex) == NGX_ERROR) {
|
if (ngx_mutex_lock(bl->mutex) == NGX_ERROR) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
rc = ngx_event_busy_lock_look_cachable(bl, ctx);
|
rc = ngx_event_busy_lock_look_cachable(bl, ctx);
|
||||||
|
|
||||||
@ -110,9 +98,7 @@ ngx_int_t ngx_event_busy_lock_cachable(ngx_event_busy_lock_t *bl,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (NGX_THREADS)
|
|
||||||
ngx_mutex_unlock(bl->mutex);
|
ngx_mutex_unlock(bl->mutex);
|
||||||
#endif
|
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@ -124,11 +110,9 @@ ngx_int_t ngx_event_busy_unlock(ngx_event_busy_lock_t *bl,
|
|||||||
ngx_event_t *ev;
|
ngx_event_t *ev;
|
||||||
ngx_event_busy_lock_ctx_t *wakeup;
|
ngx_event_busy_lock_ctx_t *wakeup;
|
||||||
|
|
||||||
#if (NGX_THREADS)
|
|
||||||
if (ngx_mutex_lock(bl->mutex) == NGX_ERROR) {
|
if (ngx_mutex_lock(bl->mutex) == NGX_ERROR) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (bl->events) {
|
if (bl->events) {
|
||||||
wakeup = bl->events;
|
wakeup = bl->events;
|
||||||
@ -140,25 +124,18 @@ ngx_int_t ngx_event_busy_unlock(ngx_event_busy_lock_t *bl,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* MP:
|
* MP: all ctx's and their queue must be in shared memory,
|
||||||
* nocachable (bl->md5 == NULL): ngx_shared_mutex_unlock(mutex, !wakeup)
|
* each ctx has pid to wake up
|
||||||
* cachable (bl->md5): ???
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (wakeup == NULL) {
|
if (wakeup == NULL) {
|
||||||
#if (NGX_THREADS)
|
|
||||||
ngx_mutex_unlock(bl->mutex);
|
ngx_mutex_unlock(bl->mutex);
|
||||||
#endif
|
|
||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->md5) {
|
if (ctx->md5) {
|
||||||
for (wakeup = bl->events; wakeup; wakeup = wakeup->next) {
|
for (wakeup = bl->events; wakeup; wakeup = wakeup->next) {
|
||||||
if (wakeup->md5 == NULL) {
|
if (wakeup->md5 == NULL || wakeup->slot != ctx->slot) {
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ngx_memcmp(ctx->md5, wakeup->md5, 16) != 0) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,30 +144,22 @@ ngx_int_t ngx_event_busy_unlock(ngx_event_busy_lock_t *bl,
|
|||||||
|
|
||||||
ev = wakeup->event;
|
ev = wakeup->event;
|
||||||
|
|
||||||
#if (NGX_THREADS)
|
|
||||||
if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_ERROR) {
|
if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_ERROR) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
ev->next = (ngx_event_t *) ngx_posted_events;
|
ev->next = (ngx_event_t *) ngx_posted_events;
|
||||||
ngx_posted_events = ev;
|
ngx_posted_events = ev;
|
||||||
|
|
||||||
#if (NGX_THREADS)
|
|
||||||
ngx_mutex_unlock(ngx_posted_events_mutex);
|
ngx_mutex_unlock(ngx_posted_events_mutex);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (NGX_THREADS)
|
|
||||||
ngx_mutex_unlock(bl->mutex);
|
ngx_mutex_unlock(bl->mutex);
|
||||||
#endif
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
bl->waiting--;
|
bl->waiting--;
|
||||||
|
|
||||||
#if (NGX_THREADS)
|
|
||||||
ngx_mutex_unlock(bl->mutex);
|
ngx_mutex_unlock(bl->mutex);
|
||||||
#endif
|
|
||||||
|
|
||||||
wakeup->handler = ngx_event_busy_lock_posted_handler;
|
wakeup->handler = ngx_event_busy_lock_posted_handler;
|
||||||
wakeup->locked = 1;
|
wakeup->locked = 1;
|
||||||
@ -201,18 +170,14 @@ ngx_int_t ngx_event_busy_unlock(ngx_event_busy_lock_t *bl,
|
|||||||
ngx_del_timer(ev);
|
ngx_del_timer(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (NGX_THREADS)
|
|
||||||
if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_ERROR) {
|
if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_ERROR) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
ev->next = (ngx_event_t *) ngx_posted_events;
|
ev->next = (ngx_event_t *) ngx_posted_events;
|
||||||
ngx_posted_events = ev;
|
ngx_posted_events = ev;
|
||||||
|
|
||||||
#if (NGX_THREADS)
|
|
||||||
ngx_mutex_unlock(ngx_posted_events_mutex);
|
ngx_mutex_unlock(ngx_posted_events_mutex);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
@ -224,11 +189,9 @@ ngx_int_t ngx_event_busy_lock_cancel(ngx_event_busy_lock_t *bl,
|
|||||||
{
|
{
|
||||||
ngx_event_busy_lock_ctx_t *c, *p;
|
ngx_event_busy_lock_ctx_t *c, *p;
|
||||||
|
|
||||||
#if (NGX_THREADS)
|
|
||||||
if (ngx_mutex_lock(bl->mutex) == NGX_ERROR) {
|
if (ngx_mutex_lock(bl->mutex) == NGX_ERROR) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
bl->waiting--;
|
bl->waiting--;
|
||||||
|
|
||||||
@ -246,9 +209,7 @@ ngx_int_t ngx_event_busy_lock_cancel(ngx_event_busy_lock_t *bl,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (NGX_THREADS)
|
|
||||||
ngx_mutex_unlock(bl->mutex);
|
ngx_mutex_unlock(bl->mutex);
|
||||||
#endif
|
|
||||||
|
|
||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
}
|
}
|
||||||
@ -276,6 +237,8 @@ static int ngx_event_busy_lock_look_cachable(ngx_event_busy_lock_t *bl,
|
|||||||
|
|
||||||
if (mask & 1) {
|
if (mask & 1) {
|
||||||
if (ngx_memcmp(&bl->md5[i * 16], ctx->md5, 16) == 0) {
|
if (ngx_memcmp(&bl->md5[i * 16], ctx->md5, 16) == 0) {
|
||||||
|
ctx->waiting = 1;
|
||||||
|
ctx->slot = i;
|
||||||
return NGX_AGAIN;
|
return NGX_AGAIN;
|
||||||
}
|
}
|
||||||
cachable++;
|
cachable++;
|
||||||
@ -319,20 +282,16 @@ static int ngx_event_busy_lock_look_cachable(ngx_event_busy_lock_t *bl,
|
|||||||
|
|
||||||
static void ngx_event_busy_lock_handler(ngx_event_t *ev)
|
static void ngx_event_busy_lock_handler(ngx_event_t *ev)
|
||||||
{
|
{
|
||||||
ev->event_handler = ngx_event_busy_lock_posted_handler;
|
|
||||||
|
|
||||||
#if (NGX_THREADS)
|
|
||||||
if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_ERROR) {
|
if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_ERROR) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
ev->next = (ngx_event_t *) ngx_posted_events;
|
ev->next = (ngx_event_t *) ngx_posted_events;
|
||||||
ngx_posted_events = ev;
|
ngx_posted_events = ev;
|
||||||
|
|
||||||
#if (NGX_THREADS)
|
|
||||||
ngx_mutex_unlock(ngx_posted_events_mutex);
|
ngx_mutex_unlock(ngx_posted_events_mutex);
|
||||||
#endif
|
|
||||||
|
ev->event_handler = ngx_event_busy_lock_posted_handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ struct ngx_event_busy_lock_ctx_s {
|
|||||||
ngx_msec_t timer;
|
ngx_msec_t timer;
|
||||||
|
|
||||||
unsigned locked:1;
|
unsigned locked:1;
|
||||||
|
unsigned waiting:1;
|
||||||
unsigned cache_updated:1;
|
unsigned cache_updated:1;
|
||||||
|
|
||||||
char *md5;
|
char *md5;
|
||||||
|
@ -40,7 +40,9 @@ ngx_http_cache_t *ngx_http_cache_get(ngx_http_cache_hash_t *hash,
|
|||||||
|
|
||||||
c = hash->elts + *crc % hash->hash * hash->nelts;
|
c = hash->elts + *crc % hash->hash * hash->nelts;
|
||||||
|
|
||||||
ngx_mutex_lock(&hash->mutex);
|
if (ngx_mutex_lock(&hash->mutex) == NGX_ERROR) {
|
||||||
|
return (void *) NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < hash->nelts; i++) {
|
for (i = 0; i < hash->nelts; i++) {
|
||||||
if (c[i].crc == *crc
|
if (c[i].crc == *crc
|
||||||
@ -95,7 +97,9 @@ ngx_http_cache_t *ngx_http_cache_alloc(ngx_http_cache_hash_t *hash,
|
|||||||
|
|
||||||
c = hash->elts + crc % hash->hash * hash->nelts;
|
c = hash->elts + crc % hash->hash * hash->nelts;
|
||||||
|
|
||||||
ngx_mutex_lock(&hash->mutex);
|
if (ngx_mutex_lock(&hash->mutex) == NGX_ERROR) {
|
||||||
|
return (void *) NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if (cache == NULL) {
|
if (cache == NULL) {
|
||||||
|
|
||||||
@ -227,14 +231,18 @@ void ngx_http_cache_free(ngx_http_cache_t *cache,
|
|||||||
|
|
||||||
void ngx_http_cache_lock(ngx_http_cache_hash_t *hash, ngx_http_cache_t *cache)
|
void ngx_http_cache_lock(ngx_http_cache_hash_t *hash, ngx_http_cache_t *cache)
|
||||||
{
|
{
|
||||||
ngx_mutex_lock(&hash->mutex);
|
if (ngx_mutex_lock(&hash->mutex) == NGX_ERROR) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ngx_http_cache_unlock(ngx_http_cache_hash_t *hash,
|
void ngx_http_cache_unlock(ngx_http_cache_hash_t *hash,
|
||||||
ngx_http_cache_t *cache, ngx_log_t *log)
|
ngx_http_cache_t *cache, ngx_log_t *log)
|
||||||
{
|
{
|
||||||
ngx_mutex_lock(&hash->mutex);
|
if (ngx_mutex_lock(&hash->mutex) == NGX_ERROR) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
cache->refs--;
|
cache->refs--;
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ extern ngx_int_t ngx_threaded;
|
|||||||
#define ngx_log_tid 0
|
#define ngx_log_tid 0
|
||||||
#define TID_T_FMT "%d"
|
#define TID_T_FMT "%d"
|
||||||
|
|
||||||
#define ngx_mutex_lock(m)
|
#define ngx_mutex_lock(m) NGX_OK
|
||||||
#define ngx_mutex_unlock(m)
|
#define ngx_mutex_unlock(m)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user