# HG changeset patch # User Igor Sysoev # Date 1089387451 0 # Node ID 79050a10aacbb25972c54461fa83bf9170c64491 # Parent e7054aaedf682f200f76249cc7de0b4dc7ad1d85 nginx-0.0.7-2004-07-09-19:37:31 import diff --git a/src/event/modules/ngx_kqueue_module.c b/src/event/modules/ngx_kqueue_module.c --- a/src/event/modules/ngx_kqueue_module.c +++ b/src/event/modules/ngx_kqueue_module.c @@ -45,7 +45,8 @@ static struct kevent *event_list; static int max_changes, nchanges, nevents; #if (NGX_THREADS) -static ngx_mutex_t *ngx_kqueue_mutex; +static ngx_mutex_t *list_mutex; +static ngx_mutex_t *kevent_mutex; #endif @@ -120,9 +121,15 @@ static ngx_int_t ngx_kqueue_init(ngx_cyc } #if (NGX_THREADS) - if (!(ngx_kqueue_mutex = ngx_mutex_init(cycle->log, 0))) { + + if (!(list_mutex = ngx_mutex_init(cycle->log, 0))) { return NGX_ERROR; } + + if (!(kevent_mutex = ngx_mutex_init(cycle->log, 0))) { + return NGX_ERROR; + } + #endif } @@ -206,7 +213,8 @@ static void ngx_kqueue_done(ngx_cycle_t ngx_kqueue = -1; #if (NGX_THREADS) - ngx_mutex_destroy(ngx_kqueue_mutex); + ngx_mutex_destroy(kevent_mutex); + ngx_mutex_destroy(list_mutex); #endif ngx_free(change_list1); @@ -233,7 +241,7 @@ static ngx_int_t ngx_kqueue_add_event(ng ev->disabled = 0; ev->oneshot = (flags & NGX_ONESHOT_EVENT) ? 1 : 0; - if (ngx_mutex_lock(ngx_kqueue_mutex) == NGX_ERROR) { + if (ngx_mutex_lock(list_mutex) == NGX_ERROR) { return NGX_ERROR; } @@ -259,7 +267,7 @@ static ngx_int_t ngx_kqueue_add_event(ng e->index = ev->index; } - ngx_mutex_unlock(ngx_kqueue_mutex); + ngx_mutex_unlock(list_mutex); return NGX_OK; } @@ -269,14 +277,14 @@ static ngx_int_t ngx_kqueue_add_event(ng ngx_log_error(NGX_LOG_ALERT, ev->log, 0, "previous event on #%d were not passed in kernel", c->fd); - ngx_mutex_unlock(ngx_kqueue_mutex); + ngx_mutex_unlock(list_mutex); return NGX_ERROR; } rc = ngx_kqueue_set_event(ev, event, EV_ADD|EV_ENABLE|flags); - ngx_mutex_unlock(ngx_kqueue_mutex); + ngx_mutex_unlock(list_mutex); return rc; } @@ -290,7 +298,7 @@ static ngx_int_t ngx_kqueue_del_event(ng ev->active = 0; ev->disabled = 0; - if (ngx_mutex_lock(ngx_kqueue_mutex) == NGX_ERROR) { + if (ngx_mutex_lock(list_mutex) == NGX_ERROR) { return NGX_ERROR; } @@ -311,7 +319,7 @@ static ngx_int_t ngx_kqueue_del_event(ng e->index = ev->index; } - ngx_mutex_unlock(ngx_kqueue_mutex); + ngx_mutex_unlock(list_mutex); return NGX_OK; } @@ -323,7 +331,7 @@ static ngx_int_t ngx_kqueue_del_event(ng */ if (flags & NGX_CLOSE_EVENT) { - ngx_mutex_unlock(ngx_kqueue_mutex); + ngx_mutex_unlock(list_mutex); return NGX_OK; } @@ -334,7 +342,7 @@ static ngx_int_t ngx_kqueue_del_event(ng rc = ngx_kqueue_set_event(ev, event, flags & NGX_DISABLE_EVENT ? EV_DISABLE : EV_DELETE); - ngx_mutex_unlock(ngx_kqueue_mutex); + ngx_mutex_unlock(list_mutex); return rc; } @@ -704,24 +712,22 @@ static ngx_int_t ngx_kqueue_process_chan struct timespec ts; struct kevent *changes; - if (try) { - rc = ngx_mutex_trylock(ngx_kqueue_mutex); - if (rc != NGX_OK) { - return rc; - } + if (ngx_mutex_lock(kevent_mutex) == NGX_ERROR) { + return NGX_ERROR; + } - } else { - if (ngx_mutex_lock(ngx_kqueue_mutex) == NGX_ERROR) { - return NGX_ERROR; - } + if (ngx_mutex_lock(list_mutex) == NGX_ERROR) { + ngx_mutex_unlock(kevent_mutex); + return NGX_ERROR; } if (nchanges == 0) { - ngx_mutex_unlock(ngx_kqueue_mutex); + ngx_mutex_unlock(list_mutex); + ngx_mutex_unlock(kevent_mutex); return NGX_OK; } - changes = (struct kevent *) change_list; + changes = change_list; if (change_list == change_list0) { change_list = change_list1; } else { @@ -731,6 +737,8 @@ static ngx_int_t ngx_kqueue_process_chan n = nchanges; nchanges = 0; + ngx_mutex_unlock(list_mutex); + ts.tv_sec = 0; ts.tv_nsec = 0; @@ -747,7 +755,7 @@ static ngx_int_t ngx_kqueue_process_chan rc = NGX_OK; } - ngx_mutex_unlock(ngx_kqueue_mutex); + ngx_mutex_unlock(kevent_mutex); return rc; } diff --git a/src/http/modules/ngx_http_ssl_filter.c b/src/http/modules/ngx_http_ssl_filter.c --- a/src/http/modules/ngx_http_ssl_filter.c +++ b/src/http/modules/ngx_http_ssl_filter.c @@ -199,7 +199,7 @@ static ngx_http_ssl_ctx_t *ngx_http_ssl_ void ngx_http_ssl_close_request(SSL *ssl, int mode) { SSL_set_shutdown(ssl, mode); - SSL_smart_shutdown(ssl); + SSL_shutdown(ssl); SSL_free(ssl); } diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c --- a/src/http/ngx_http_request.c +++ b/src/http/ngx_http_request.c @@ -815,7 +815,7 @@ static ssize_t ngx_http_read_request_hea return NGX_AGAIN; } -#if 1 +#if 0 ngx_http_ssl_read(r); #else n = ngx_recv(r->connection, r->header_in->last,