diff src/event/ngx_event_busy_lock.c @ 112:408f195b3482 NGINX_0_3_3

nginx 0.3.3 *) Change: the "bl" and "af" parameters of the "listen" directive was renamed to the "backlog" and "accept_filter". *) Feature: the "rcvbuf" and "sndbuf" parameters of the "listen" directive. *) Change: the "$msec" log parameter does not require now the additional the gettimeofday() system call. *) Feature: the -t switch now tests the "listen" directives. *) Bugfix: if the invalid address was specified in the "listen" directive, then after the -HUP signal nginx left an open socket in the CLOSED state. *) Bugfix: the mime type may be incorrectly set to default value for index file with variable in the name; bug appeared in 0.3.0. *) Feature: the "timer_resolution" directive. *) Feature: the millisecond "$upstream_response_time" log parameter. *) Bugfix: a temporary file with client request body now is removed just after the response header was transferred to a client. *) Bugfix: OpenSSL 0.9.6 compatibility. *) Bugfix: the SSL certificate and key file paths could not be relative. *) Bugfix: the "ssl_prefer_server_ciphers" directive did not work in the ngx_imap_ssl_module. *) Bugfix: the "ssl_protocols" directive allowed to specify the single protocol only.
author Igor Sysoev <http://sysoev.ru>
date Wed, 19 Oct 2005 00:00:00 +0400
parents b55cbf18157e
children bb61aa162c6b
line wrap: on
line diff
--- a/src/event/ngx_event_busy_lock.c
+++ b/src/event/ngx_event_busy_lock.c
@@ -10,7 +10,7 @@
 
 
 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);
 static void ngx_event_busy_lock_handler(ngx_event_t *ev);
 static void ngx_event_busy_lock_posted_handler(ngx_event_t *ev);
 
@@ -23,14 +23,12 @@ static void ngx_event_busy_lock_posted_h
  * NGX_ERROR:  an error occured while the mutex locking
  */
 
-ngx_int_t ngx_event_busy_lock(ngx_event_busy_lock_t *bl,
-                              ngx_event_busy_lock_ctx_t *ctx)
+ngx_int_t
+ngx_event_busy_lock(ngx_event_busy_lock_t *bl, ngx_event_busy_lock_ctx_t *ctx)
 {
     ngx_int_t  rc;
 
-    if (ngx_mutex_lock(bl->mutex) == NGX_ERROR) {
-        return NGX_ERROR;
-    }
+    ngx_mutex_lock(bl->mutex);
 
     ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ctx->event->log, 0,
                    "event busy lock: b:%d mb:%d",
@@ -66,14 +64,13 @@ ngx_int_t ngx_event_busy_lock(ngx_event_
 }
 
 
-ngx_int_t ngx_event_busy_lock_cachable(ngx_event_busy_lock_t *bl,
-                                       ngx_event_busy_lock_ctx_t *ctx)
+ngx_int_t
+ngx_event_busy_lock_cachable(ngx_event_busy_lock_t *bl,
+    ngx_event_busy_lock_ctx_t *ctx)
 {
     ngx_int_t  rc;
 
-    if (ngx_mutex_lock(bl->mutex) == NGX_ERROR) {
-        return NGX_ERROR;
-    }
+    ngx_mutex_lock(bl->mutex);
 
     rc = ngx_event_busy_lock_look_cachable(bl, ctx);
 
@@ -112,15 +109,14 @@ ngx_int_t ngx_event_busy_lock_cachable(n
 }
 
 
-ngx_int_t ngx_event_busy_unlock(ngx_event_busy_lock_t *bl,
-                                ngx_event_busy_lock_ctx_t *ctx)
+void
+ngx_event_busy_unlock(ngx_event_busy_lock_t *bl,
+    ngx_event_busy_lock_ctx_t *ctx)
 {
     ngx_event_t                *ev;
     ngx_event_busy_lock_ctx_t  *wakeup;
 
-    if (ngx_mutex_lock(bl->mutex) == NGX_ERROR) {
-        return NGX_ERROR;
-    }
+    ngx_mutex_lock(bl->mutex);
 
     if (bl->events) {
         wakeup = bl->events;
@@ -138,7 +134,7 @@ ngx_int_t ngx_event_busy_unlock(ngx_even
 
     if (wakeup == NULL) {
         ngx_mutex_unlock(bl->mutex);
-        return NGX_OK;
+        return;
     }
 
     if (ctx->md5) {
@@ -152,13 +148,7 @@ ngx_int_t ngx_event_busy_unlock(ngx_even
 
             ev = wakeup->event;
 
-            if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_ERROR) {
-                return NGX_ERROR;
-            }
-
-            ngx_post_event(ev);
-
-            ngx_mutex_unlock(ngx_posted_events_mutex);
+            ngx_post_event(ev, &ngx_posted_events);
         }
 
         ngx_mutex_unlock(bl->mutex);
@@ -177,27 +167,18 @@ ngx_int_t ngx_event_busy_unlock(ngx_even
             ngx_del_timer(ev);
         }
 
-        if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_ERROR) {
-            return NGX_ERROR;
-        }
-
-        ngx_post_event(ev);
-
-        ngx_mutex_unlock(ngx_posted_events_mutex);
+        ngx_post_event(ev, &ngx_posted_events);
     }
-
-    return NGX_OK;
 }
 
 
-ngx_int_t ngx_event_busy_lock_cancel(ngx_event_busy_lock_t *bl,
-                                     ngx_event_busy_lock_ctx_t *ctx)
+void
+ngx_event_busy_lock_cancel(ngx_event_busy_lock_t *bl,
+    ngx_event_busy_lock_ctx_t *ctx)
 {
     ngx_event_busy_lock_ctx_t  *c, *p;
 
-    if (ngx_mutex_lock(bl->mutex) == NGX_ERROR) {
-        return NGX_ERROR;
-    }
+    ngx_mutex_lock(bl->mutex);
 
     bl->waiting--;
 
@@ -216,13 +197,12 @@ ngx_int_t ngx_event_busy_lock_cancel(ngx
     }
 
     ngx_mutex_unlock(bl->mutex);
-
-    return NGX_OK;
 }
 
 
-static int ngx_event_busy_lock_look_cachable(ngx_event_busy_lock_t *bl,
-                                             ngx_event_busy_lock_ctx_t *ctx)
+static ngx_int_t
+ngx_event_busy_lock_look_cachable(ngx_event_busy_lock_t *bl,
+    ngx_event_busy_lock_ctx_t *ctx)
 {
     ngx_int_t    free;
     ngx_uint_t   i, bit, cachable, mask;
@@ -286,21 +266,17 @@ static int ngx_event_busy_lock_look_cach
 }
 
 
-static void ngx_event_busy_lock_handler(ngx_event_t *ev)
+static void
+ngx_event_busy_lock_handler(ngx_event_t *ev)
 {
-    if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_ERROR) {
-        return;
-    }
+    ev->handler = ngx_event_busy_lock_posted_handler;
 
-    ngx_post_event(ev);
-
-    ngx_mutex_unlock(ngx_posted_events_mutex);
-
-    ev->handler = ngx_event_busy_lock_posted_handler;
+    ngx_post_event(ev, &ngx_posted_events);
 }
 
 
-static void ngx_event_busy_lock_posted_handler(ngx_event_t *ev)
+static void
+ngx_event_busy_lock_posted_handler(ngx_event_t *ev)
 {
     ngx_event_busy_lock_ctx_t  *ctx;