This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Detect "(!) timer drift -- spun"

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
SaPrOuZy
Halfop
Posts: 75
Joined: Wed Mar 24, 2004 7:38 am
Location: Lebanon

Detect "(!) timer drift -- spun"

Post by SaPrOuZy »

Hey all,
is there a way to detect "(!) timer drift -- spun X minutes" i have a join flood protection script that i want to disable when this happens because it will mistake normal joins with floods. i have a lag check incorporated in the script, it works fine when the bot is lagging due to connection problem but when the eggdrop process by it self is having problems (CPU time or whatever) my lag check fails since it can't run.

now if there is a bind or something to detect "(!) timer drift -- spun X minutes" then it would be more effective than having a lag check every x minutes.

thanks in advance.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

The only thing that will trigger after 'timer drift' is the HOOK_MINUTELY (once for each minute "missed"). This in its turn will trigger a check for time-bindings, so I guess this might be a way of writing a detector of some sort (checking if a time-binding triggers several times within a very short timespan).

There is, however, no direct hook or trigger for timer drift, so you'll be forced to write your own detector.
NML_375
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Weird Messages That Get Logged:
(!) timer drift -- spun N minutes

This can be caused by one of several reasons.

- Your bot could have been swapped out of memory for a while, or for
some reason the computer could have stopped letting the bot run. Once
a minute, Eggdrop does a few maintenance things, including counting
down any active Tcl timers. If for some reason, several minutes pass
without Eggdrop being able to do this, it logs this message to let
you know what happened. It's generally a bad thing, because it means
that the system your bot is on is very busy, and the bot can hardly
keep track of the channel very well when it gets swapped out for
minutes at a time.

- On some systems (at least Linux), if the DNS your bot is using to
lookup hostnames is broken and *very* slow in responding (this can
occur if the DNS server's uplink doesn't exist), then you will get
4-5 minute timer drifts continuously. This can be fixed by loading
the dns module.

- The clock on your machine has just been changed. It may have been
running behind by several minutes and was just corrected.
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

Something like this might work (not tested):

Code: Select all

bind time - * {set lastminute [clock sec];#}

proc yourjoinfloodprotectionscript {} {
	if {$::lastminute<([clock sec]-60)} {
		# timer drift...don't kick?
	} {
		# work as normal
	}
}
Have you ever read "The Manual"?
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

I'm afraid that will not work, as the timestamp used to trigger the time-binding is "current" even in the timer-drift condition.
The effect however, would be that the time-binding will trigger multiple times with the same minute-value.
NML_375
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Code: Select all

bind time - * checkdrift
set _lastmin 0

proc checkdrift {args} {
 global _lastmin timerdrift
 if {${_lastmin} == [lindex $args 0]} {
  set timerdrift 1
 } {
  set timerdrift 0
  set _lastmin [lindex $args 0]
 }
}
I believe this code would set the globalspace variable timerdrift to 1 when a timerdrift conditon occurs, and resets it to 0 upon next "proper" HOOK_MINUTELY hook. However, this code has not been tested either.

Worth noting, one of the most common causes for timerdrifts are tcl-scripts that do some heavy data manipulation (or invokes an external application to do it, such as pisg), or ftp-scripts. This is due to the fact that eggdrop only uses one tcl-interpreter and no further threads; and will only execute one (tcl) command at any single time.
NML_375
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

Good to know. I get them quite a bit from my old p2 lagging.
Post Reply