nxt_log_moderation.c (0:a63ceefd6ab0) nxt_log_moderation.c (1:fdc027c56872)
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_main.h>
8
9
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_main.h>
8
9
10static void nxt_log_moderate_timer_handler(nxt_thread_t *thr, void *obj,
10static void nxt_log_moderate_timer_handler(nxt_task_t *task, void *obj,
11 void *data);
12
13
14nxt_bool_t
15nxt_log_moderate_allow(nxt_log_moderation_t *mod)
16{
17 nxt_uint_t n;
18 nxt_time_t now;

--- 46 unchanged lines hidden (view full) ---

65 nxt_event_timer_add(thr->engine, &mod->timer, 1000);
66 }
67
68 return allow;
69}
70
71
72static void
11 void *data);
12
13
14nxt_bool_t
15nxt_log_moderate_allow(nxt_log_moderation_t *mod)
16{
17 nxt_uint_t n;
18 nxt_time_t now;

--- 46 unchanged lines hidden (view full) ---

65 nxt_event_timer_add(thr->engine, &mod->timer, 1000);
66 }
67
68 return allow;
69}
70
71
72static void
73nxt_log_moderate_timer_handler(nxt_thread_t *thr, void *obj, void *data)
73nxt_log_moderate_timer_handler(nxt_task_t *task, void *obj, void *data)
74{
75 nxt_bool_t msg;
76 nxt_atomic_uint_t n;
77 nxt_event_timer_t *ev;
78 nxt_log_moderation_t *mod;
79
80 ev = obj;
81 mod = nxt_event_timer_data(ev, nxt_log_moderation_t, timer);
82
83 nxt_thread_spin_lock(&mod->lock);
84
74{
75 nxt_bool_t msg;
76 nxt_atomic_uint_t n;
77 nxt_event_timer_t *ev;
78 nxt_log_moderation_t *mod;
79
80 ev = obj;
81 mod = nxt_event_timer_data(ev, nxt_log_moderation_t, timer);
82
83 nxt_thread_spin_lock(&mod->lock);
84
85 mod->last = nxt_thread_time(thr);
85 mod->last = nxt_thread_time(task->thread);
86 n = mod->count;
87 mod->count = 0;
88 msg = (mod->pid == nxt_pid);
89
90 nxt_thread_spin_unlock(&mod->lock);
91
92 if (msg) {
93 nxt_log_error(mod->level, &nxt_main_log, "%s %uA times",
94 mod->msg, n - mod->limit);
95 }
96}
86 n = mod->count;
87 mod->count = 0;
88 msg = (mod->pid == nxt_pid);
89
90 nxt_thread_spin_unlock(&mod->lock);
91
92 if (msg) {
93 nxt_log_error(mod->level, &nxt_main_log, "%s %uA times",
94 mod->msg, n - mod->limit);
95 }
96}