diff options
author | Andrei Belov <defan@nginx.com> | 2021-12-02 18:42:23 +0300 |
---|---|---|
committer | Andrei Belov <defan@nginx.com> | 2021-12-02 18:42:23 +0300 |
commit | 7634ab0f21c712e79c5d09e5817f866ff71d4f49 (patch) | |
tree | 1c4b20be29a9372858088c9faa3f02e7f584402f /src/nxt_router.c | |
parent | 5dfde9717d9ef611072defdd211089efa920c728 (diff) | |
parent | 85908c09f9b7d8d0bd797427d984e2697ece8267 (diff) | |
download | unit-7634ab0f21c712e79c5d09e5817f866ff71d4f49.tar.gz unit-7634ab0f21c712e79c5d09e5817f866ff71d4f49.tar.bz2 |
Merged with the 1.26 branch.1.26.1-1
Diffstat (limited to 'src/nxt_router.c')
-rw-r--r-- | src/nxt_router.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/src/nxt_router.c b/src/nxt_router.c index 7623ccbb..85556a72 100644 --- a/src/nxt_router.c +++ b/src/nxt_router.c @@ -210,6 +210,8 @@ static void nxt_router_access_log_ready(nxt_task_t *task, nxt_port_recv_msg_t *msg, void *data); static void nxt_router_access_log_error(nxt_task_t *task, nxt_port_recv_msg_t *msg, void *data); +static void nxt_router_access_log_use(nxt_thread_spinlock_t *lock, + nxt_router_access_log_t *access_log); static void nxt_router_access_log_release(nxt_task_t *task, nxt_thread_spinlock_t *lock, nxt_router_access_log_t *access_log); static void nxt_router_access_log_reopen_completion(nxt_task_t *task, void *obj, @@ -1149,7 +1151,13 @@ nxt_router_conf_apply(nxt_task_t *task, void *obj, void *data) nxt_queue_add(&router->sockets, &updating_sockets); nxt_queue_add(&router->sockets, &creating_sockets); - router->access_log = rtcf->access_log; + if (router->access_log != rtcf->access_log) { + nxt_router_access_log_use(&router->lock, rtcf->access_log); + + nxt_router_access_log_release(task, &router->lock, router->access_log); + + router->access_log = rtcf->access_log; + } nxt_router_conf_ready(task, tmcf); @@ -1971,9 +1979,7 @@ nxt_router_conf_create(nxt_task_t *task, nxt_router_temp_conf_t *tmcf, access_log = router->access_log; if (access_log != NULL && nxt_strstr_eq(&path, &access_log->path)) { - nxt_thread_spin_lock(&router->lock); - access_log->count++; - nxt_thread_spin_unlock(&router->lock); + nxt_router_access_log_use(&router->lock, access_log); } else { access_log = nxt_malloc(sizeof(nxt_router_access_log_t) @@ -3923,6 +3929,22 @@ nxt_router_access_log_error(nxt_task_t *task, nxt_port_recv_msg_t *msg, static void +nxt_router_access_log_use(nxt_thread_spinlock_t *lock, + nxt_router_access_log_t *access_log) +{ + if (access_log == NULL) { + return; + } + + nxt_thread_spin_lock(lock); + + access_log->count++; + + nxt_thread_spin_unlock(lock); +} + + +static void nxt_router_access_log_release(nxt_task_t *task, nxt_thread_spinlock_t *lock, nxt_router_access_log_t *access_log) { |