Changeset 5aa23b55a4547257580d047118ec4019a93499f7
- Timestamp:
- 08/19/08 22:30:14
(3 months ago)
- Author:
- Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
- git-committer:
- Giuseppe Bilotta <giuseppe.bilotta@gmail.com> 1219170614 +0200
- git-parent:
[43b5cd9777cc13c6d3ac14a4015a0c8e8d9e5b50]
- git-author:
- Giuseppe Bilotta <giuseppe.bilotta@gmail.com> 1219170614 +0200
- Message:
IRC socket: minor flood_send logic fixes
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r43b5cd9 |
r5aa23b5 |
|
| 397 | 397 | begin |
|---|
| 398 | 398 | now = Time.now |
|---|
| 399 | | flood_delay = @flood_send - MAX_IRC_SEND_PENALTY - now |
|---|
| 400 | | delay = [flood_delay, 0].max |
|---|
| 401 | | if delay > 0 |
|---|
| | 399 | flood_delay = @flood_send - MAX_IRC_SEND_PENALTY - now |
|---|
| | 400 | delay = [flood_delay, 0].max |
|---|
| | 401 | if delay > 0 |
|---|
| 402 | 402 | debug "sleep(#{delay}) # (f: #{flood_delay})" |
|---|
| 403 | 403 | sleep(delay) |
|---|
| 404 | 404 | end |
|---|
| 405 | 405 | msg = @sendq.shift |
|---|
| 406 | | now = Time.now |
|---|
| 407 | | @flood_send = now if @flood_send < now |
|---|
| 408 | 406 | debug "got #{msg.inspect} from queue, sending" |
|---|
| 409 | 407 | emergency_puts(msg, true) |
|---|
| … | … | |
| 428 | 426 | # some circumstances |
|---|
| 429 | 427 | actual = @filter.out(message) + "\n" |
|---|
| | 428 | now = Time.new |
|---|
| 430 | 429 | @sock.syswrite actual |
|---|
| 431 | | @last_send = Time.new |
|---|
| | 430 | @last_send = now |
|---|
| | 431 | @flood_send = now if @flood_send < now |
|---|
| 432 | 432 | @flood_send += message.irc_send_penalty if penalty |
|---|
| 433 | 433 | @lines_sent += 1 |
|---|