mIRC Home    About    Download    Register    News    Help

Print Thread
#123953 30/06/05 02:50 AM
Joined: Dec 2002
Posts: 580
N
Fjord artisan
OP Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 580
I've not seen anything like this, so I thought others would appreciate seeing the script I've come up with... The script stops events from happening for five minutes, if a timer that runs every 5 seconds starts to overlap when the following occurance of the timer should occur.
Code:
on *:start:{ .timer 0 5 watchdog }
alias watchdog {
  ; Setup a $tick monitoring watchdog
  if (!%~WatchdogOffTime) { set %~WatchdogOffTime 5 }
  if (!%~WatchdogTickCount) { set %~WatchdogTickCount 10000 }
  if (!$timer(Watchdog)) && (%~LastTicksWatchdog) && ($calc($ticks - %~LastTicksWatchdog) > %~WatchdogTickCount) {
    .remote off | .timerWatchDog off | .timerWatchdog 1 $calc(%~WatchdogOffTime * 60) reenable.remote
    echo -a  Disabling all script events because of watchdog. Elapsed = $calc($ticks - %~LastTicksWatchdog)) $+ . 
    echo -a Will automatically reenable in %~WatchdogOffTime minutes.
  }
  else { set %~LastTicksWatchdog $ticks }
}
alias reenable.remote {
  .timerWatchdog off
  set %~LastTicksWatchdog $ticks
  .remote on
  echo -a Watchdog has reenabled event processing.
}


NaquadaBomb
www.mirc-dll.com
#123954 30/06/05 09:03 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
You have a repeating 5 second timer that checks if its been more than 10 seconds since the last occurance, if so then it shuts remotes down for 5 minutes.

Can you explain a use for this, becuase the purpose eludes me.
(I did understand how it can have elapsed over 10 seconds, and how it checks for the 5 minute restarter running etc)

#123955 02/07/05 10:17 AM
Joined: Dec 2002
Posts: 580
N
Fjord artisan
OP Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 580
If a timer that should execute every 5 seconds takes 10 seconds (numbers adjustable). There is something likely wrong, such as being stuck in an infinate loop or being flooded. To help stabilze things, event processing is stopped. Could also kill timers, etc... It nice for those of us running nearly one meg of scripts. Would also like to see a command that will stop all events/aliases currently running, sort of a control-break via scripts.


NaquadaBomb
www.mirc-dll.com
#123956 02/07/05 11:32 AM
Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
Since the timer will only run after some script completes, it will not help for infinite loops. It will also not help with things that take to long and thus disconnect you from irc, like $crc of a few megabyte.
Might be ok for some scripted quit/joins at a netsplit in a really big channel and the like...

#123957 02/07/05 10:18 PM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
As already said to you, your idea wont work due to the way no other task is performed untill the currently running script completes, ie: infinite loop completes (an unlikely occurance!)
While it might help in shutting down events in some instances of high levels of events triggering causing you to lag out such as a netsplit/join or an attack on a scripted event, I would say it would be far more clever to script protection into those events.

If you want to controll possable flooding problems i would look to a debug session, which deactivates events, however thats quite a big task to craft it correctly.

Quote:
It nice for those of us running nearly one meg of scripts.

Sounds like your relying on a bulk of other peoples scripts to be getting that higher size, I have found that often scripts compete with each other causing more trouble.

Quote:
Would also like to see a command that will stop all events/aliases currently running, sort of a control-break via scripts.

Stopall { !debug off | !remote off | timer* off }

^ that of course must get a chance to run, which means the system has at least freed up for the moment that it is run!

#123958 03/07/05 10:37 PM
Joined: Dec 2002
Posts: 580
N
Fjord artisan
OP Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 580
Not always true. It is posible to prevent a loop from holding up processing of events. Using signals and timers. Really intense loops could be implemented in this way...
Code:
; *** Multi-Threaded Looping, using Timers ***

; Starts everything going
alias test {
  set %LoopCount 1
  .signal do_echo | .signal do_loop
}

; do_loop will not stop looping,
; nor will this type of looping stop event processing
on *:signal:do_loop {
  inc %LoopCount | .timerSig1 1 0 .signal $signal
  halt | :error
  echo -a Break in $signal at LoopCount of %LoopCount $+ . $error
  .timerSig1 off | .timerSig2 off | reseterror
}

; do_echo will stop when loop count is >= 1000
; and also stop script processing, stoping the first loop
; Like the prior loop does not stop event proesssing
on *:signal:do_echo {
  if (%LoopCount < 999) {
    echo -a Loop Count: %LoopCount
    .timerSig2 1 0 .signal $signal
  }
  else { remote off | .timerSig1 off | .timerSig2 off }
  halt | :error
  echo -a Break in $signal at LoopCount of %LoopCount $+ . $error
  .timerSig1 off | .timerSig2 off | reseterror
}


NaquadaBomb
www.mirc-dll.com

Link Copied to Clipboard