SA-MP Forums

Go Back   SA-MP Forums > SA-MP Server > Server Support

Reply
 
Thread Tools Display Modes
Old 01/03/2013, 09:40 PM   #1
Tomboeg
Gangsta
 
Tomboeg's Avatar
 
Join Date: Aug 2010
Location: Somewhere between 0.2x and 0.3a.
Posts: 829
Reputation: 661
Default How to prevent server loops?

Hello.

Today i've got a question regarding server loops.

What happens if a server randomly loops.
I was wondering if you guys can inform me more on it.

When it loops it stays on for example: 25/500
Then nobody is able to enter the server and it's also not responding to rcon commands of any kind.
Only solution is to kill the process and to restart the server.

Problem would be that the server randomly starts to loop.

So basically i'm asking you guys if you know what to do against and how to prevent loops
Any advice, opinions?
__________________
Steam:

Twitch:

Last edited by Tomboeg; 20/03/2013 at 10:36 PM.
Tomboeg is offline   Reply With Quote
Old 01/03/2013, 09:44 PM   #2
Vince
Spam Machine
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 10,995
Reputation: 2647
Default Re: How to prevent server loops?

Add prints before and after every loop. The problem is most likely in a faulty while loop so check those first. The server doesn't just hang by itself.
__________________
Vince is offline   Reply With Quote
Old 01/03/2013, 09:51 PM   #3
AndreT
Gangsta
 
AndreT's Avatar
 
Join Date: Jul 2011
Posts: 977
Reputation: 410
Default Re: How to prevent server loops?

I think we are on a different understanding of what loops are here.

I have myself had problems with lockups - situations where the script thread of the SA-MP server is stuck doing something over and over, but the network thread is running (and accepting connections and trying to have the script thread handle them without any luck). In these cases, all that can be done is a simple restart.

There are a few ways to approach this. One would be, as Vince already pointed out, adding debugging to loops in your code to see if that might be the fault. If it is, then it is easily detectable and you're lucky it happens at your script's level.

However the more plugins you use, the larger the potential chance of issues caused by them. Bugs can occur and sometimes it is hard to trace them down (crashdetect does not catch these of course), but if you're on linux, run your server in gdb and that will help you a great deal to see what's going on. Or you can also try attaching strace to your server process.
AndreT is offline   Reply With Quote
Old 03/03/2013, 11:33 AM   #4
Tomboeg
Gangsta
 
Tomboeg's Avatar
 
Join Date: Aug 2010
Location: Somewhere between 0.2x and 0.3a.
Posts: 829
Reputation: 661
Default Re: How to prevent server loops?

Thanks for the help.

We've tried adding prints without result so far.

We're trying several things without success anyone got some other idea?
__________________
Steam:

Twitch:
Tomboeg is offline   Reply With Quote
Old 03/03/2013, 11:45 AM   #5
RajatPawar
High-roller
 
RajatPawar's Avatar
 
Join Date: Aug 2011
Location: ヽ༼ຈل͜ຈ༽ノ
Posts: 2,287
Reputation: 311
Default Re: How to prevent server loops?

You can't 'prevent' loops, the server won't automatically start these loops, you got a mistake in one of your loops, so try debugging them!
RajatPawar is offline   Reply With Quote
Old 03/03/2013, 11:50 AM   #6
Babul
High-roller
 
Babul's Avatar
 
Join Date: Sep 2009
Location: in a cement block
Posts: 1,893
Reputation: 251
Default Re: How to prevent server loops?

check all your function calls. i could place a wager on a recursion problem:
Code:
stock a(){
	new bla=b();
	return 1;
}
stock b(){
	new bla=a();
	return 1;
}
add that upper crap to your script, and call it per command. plop: server frozen, until the heap gets filled up. then the server should crash and restart.
hm. when you get to execute the upper recursion, clock the time it needs to restart.
btw, the recursion bug will NOT get noticed by the compiler. you see the problem?

ok, which callbacks could be interesting?... in your script, is there a distane check which calls a selfmade sqrt() function maybe? a quicksort()? or a fibbonaci generator? it could even be a random lotto() generator which calls itself when a number already was chosen, or a random weapon surprise for a player...

addition: the assert() function acts like a if(), BUT it exits the server when the statement is not true.
combining this with a GetTickCount() in each suspicious function, you could let check a function ITSELF how often it gets called (by itself or other function). if its belongs to a timer, then you know to raise the difference (in ms indeed) for the time-difference-estimation. or better, first ignore timer-functions.
__________________
FireWorks

new sscanf2 custom specifiers available for Download, read the Release Topic
Babul is offline   Reply With Quote
Old 03/03/2013, 01:45 PM   #7
xeeZ
Huge Clucker
 
Join Date: Feb 2013
Posts: 318
Reputation: 382
Default Re: How to prevent server loops?

Try interruptting the server with Ctrl-C (or sending SIGINT if it's Linux) and looking at the stack trace outputted by CrashDetect. The top most thing should be the place where your code gets stuck.
xeeZ is offline   Reply With Quote
Old 13/03/2013, 09:39 PM   #8
Tomboeg
Gangsta
 
Tomboeg's Avatar
 
Join Date: Aug 2010
Location: Somewhere between 0.2x and 0.3a.
Posts: 829
Reputation: 661
Default Re: How to prevent server loops?

Yea well we tried multiple things.

When it loops it just randomly starts to loop in the middle of a match.
Prints haven't brought any results, we did all we could. I'm pretty much losing hope.

Anyone knows what to do?
__________________
Steam:

Twitch:
Tomboeg is offline   Reply With Quote
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Server just crashed AGAIN, what can i script to prevent this? denNorske Scripting Help 6 04/09/2012 02:48 PM
How to prevent server from crashing during car explosion. ShawtyyMacJunior Scripting Help 8 31/07/2012 07:34 AM
[Include] GUIS - Prevent people from hacking your server (Updated v1.2) i514x Includes 21 20/09/2011 07:54 PM
How to prevent the flood attack on sa-mp server 03A R7? Makero1 Server Support 0 11/06/2010 12:47 PM
How To make Password Team Prevent All Player Come to server jame20702 Help Archive 3 13/01/2010 11:34 AM


All times are GMT. The time now is 05:55 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.