Raised This Month: $12 Target: $400
 3% 

New Feature: Watchdog Timer


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BAILOPAN
Join Date: Jan 2004
Old 08-15-2013 , 02:56   New Feature: Watchdog Timer
Reply With Quote #1

Hi All,

If you're using SourceMod 1.6 snapshots, I've just added an experimental feature. If a plugin takes too long to execute - for example, it has a bug that causes your server to hang or infinite loop - SourceMod will now try to terminate the plugin. If that happens you'll get an error like this:

Code:
L 08/14/2013 - 23:47:20: [SM] Plugin encountered error 30: Script execution timed out
L 08/14/2013 - 23:47:20: [SM] Displaying call stack trace for plugin "test.smx":
L 08/14/2013 - 23:47:20: [SM]   [0]  Line 13, test.sp::OnPluginStart()
This feature is zero-cost and should not incur any performance overhead. I've also taken care to make sure it doesn't introduce spurious timeouts where none occurred. However, if you find any bugs, please do let me know.

The timeout can be configured or disabled in core.cfg via the new "SlowScriptTimeout" option. It defaults to 8 seconds.

Thanks!
__________________
egg

Last edited by BAILOPAN; 08-15-2013 at 03:00.
BAILOPAN is offline
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 08-15-2013 , 03:11   Re: New Feature: Watchdog Timer
Reply With Quote #2

What exactly is watchdog? Ages ago I set -nowatchdog in my startup line and I honestly can't even remember why.

Pretty neat feature though
hlstriker is offline
BAILOPAN
Join Date: Jan 2004
Old 08-15-2013 , 03:15   Re: New Feature: Watchdog Timer
Reply With Quote #3

It's a general term for anything that watches to make sure nothing's malfunctioning. Like when a webpage takes too long to load, most browsers have a "This script is taking too long..." dialog. That's a watchdog timer of some kind.
__________________
egg
BAILOPAN is offline
Sreaper
髪を用心
Join Date: Nov 2009
Old 08-15-2013 , 04:32   Re: New Feature: Watchdog Timer
Reply With Quote #4

Awesome! Thanks Bailopan!
Sreaper is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 08-15-2013 , 08:25   Re: New Feature: Watchdog Timer
Reply With Quote #5

It'll be interesting to see what plugins actually reach such a timeout. I'd expect it to be very rare?
__________________
Peace-Maker is offline
LouLouBizou
Member
Join Date: Aug 2006
Location: Toulouse (France)
Old 08-15-2013 , 11:24   Re: New Feature: Watchdog Timer
Reply With Quote #6

heap memoty leak fixed in last dev 1.6 ?
__________________
LouLouBizou alias Don French !



Last edited by LouLouBizou; 08-15-2013 at 11:25.
LouLouBizou is offline
Send a message via MSN to LouLouBizou
BAILOPAN
Join Date: Jan 2004
Old 08-15-2013 , 13:21   Re: New Feature: Watchdog Timer
Reply With Quote #7

Quote:
Originally Posted by Peace-Maker View Post
It'll be interesting to see what plugins actually reach such a timeout. I'd expect it to be very rare?
I would expect it to be rare as well. It may end up being more of a developer feature, everyone's probably accidentally locked up their server once or twice writing a complex plugin.
__________________
egg
BAILOPAN is offline
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 08-15-2013 , 14:53   Re: New Feature: Watchdog Timer
Reply With Quote #8

once or twice? I've been doing it a few times a week for three years. tis a wonderful feature xD.
__________________
thetwistedpanda is offline
ElooKoN
        ^_^
Join Date: Apr 2011
Old 11-04-2015 , 11:33   Re: New Feature: Watchdog Timer
Reply With Quote #9

Good feature!

But today I got this error message. Probably caused by slow hardware I/O because the error occurred after rebooting the physical machine:

Code:
L 11/04/2015 - 11:00:12: [SM] Plugin encountered error 30: Script execution timed out
L 11/04/2015 - 11:00:12: [SM] Displaying call stack trace for plugin "Plugin.smx":
L 11/04/2015 - 11:00:12: [SM]   [0]  Line 329, addons/sourcemod/scripting/include/string.inc::StrEqual()
L 11/04/2015 - 11:00:12: [SM]   [1]  Line 2551, inc/common.inc.compile::RemoveOldFiles()
L 11/04/2015 - 11:00:12: [SM]   [2]  Line 2543, inc/common.inc.compile::TidyUp()
L 11/04/2015 - 11:00:12: [SM]   [3]  Line 105, base.inc.compile::OnPluginStart()
I am wondering why it stops at StrEqual() and not at ReadDirEntry() or OpenDirectory()?

Code:
stock RemoveOldFiles(const String:directory[], const MaxAge) {
	
	new FileTime;
	
	decl String:filename[32];
	decl String:FilePath[64];
	
	new Handle:dir = OpenDirectory(directory);
	
	while (ReadDirEntry(dir, filename, sizeof(filename))) {
	
		if (!StrEqual(filename, ".") && !StrEqual(filename, "..")) {
			
			...
		
		}

	}
	
	CloseHandle(dir);
	
}
Maybe it is a bug of StrEqual(). Line 329 in string.inc is:

Code:
native bool:IsCharAlpha(chr);
I'm using Sourcemod 1.7, Build 5272.
ElooKoN is offline
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 11-04-2015 , 12:51   Re: New Feature: Watchdog Timer
Reply With Quote #10

I think the watchdog timer begins a timer when a function in the plugin is first invoked, and if the whole operation takes more than 8 seconds it just kills the entire stack. I'm not sure however.
Potato Uno is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:26.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode