diff options
author | Ralf Baechle <ralf@linux-mips.org> | 1999-10-09 00:00:47 +0000 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 1999-10-09 00:00:47 +0000 |
commit | d6434e1042f3b0a6dfe1b1f615af369486f9b1fa (patch) | |
tree | e2be02f33984c48ec019c654051d27964e42c441 /net/core/utils.c | |
parent | 609d1e803baf519487233b765eb487f9ec227a18 (diff) |
Merge with 2.3.19.
Diffstat (limited to 'net/core/utils.c')
-rw-r--r-- | net/core/utils.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/net/core/utils.c b/net/core/utils.c index 415926b8e..310393453 100644 --- a/net/core/utils.c +++ b/net/core/utils.c @@ -46,21 +46,28 @@ int net_msg_burst = 10*5*HZ; */ int net_ratelimit(void) { + static spinlock_t ratelimit_lock = SPIN_LOCK_UNLOCKED; static unsigned long toks = 10*5*HZ; static unsigned long last_msg; static int missed; + unsigned long flags; unsigned long now = jiffies; - toks += now - xchg(&last_msg, now); + spin_lock_irqsave(&ratelimit_lock, flags); + toks += now - last_msg; + last_msg = now; if (toks > net_msg_burst) toks = net_msg_burst; if (toks >= net_msg_cost) { - toks -= net_msg_cost; - if (missed) - printk(KERN_WARNING "NET: %d messages suppressed.\n", missed); + int lost = missed; missed = 0; + toks -= net_msg_cost; + spin_unlock_irqrestore(&ratelimit_lock, flags); + if (lost) + printk(KERN_WARNING "NET: %d messages suppressed.\n", lost); return 1; } - missed++; + missed++; + spin_unlock_irqrestore(&ratelimit_lock, flags); return 0; } |