GetPlayerNetworkStats() crash the server
#1

I'm an owner of a large project with few servers.
Every one or two days one of our servers crashed for inexplicable reason.
I'm had installed creshdetect plugin, this detects that crash is caused by GetPlayerNetworkStats() function.

Server version: 0.3x-R2-1000p patch 1

In server.log before crash:
Код HTML:
[19/01/2014 17:54:41] [debug] Server crashed while executing rp.amx
[19/01/2014 17:54:41] [debug] AMX backtrace:
[19/01/2014 17:54:41] [debug] #0 native GetPlayerNetworkStats () [080d0e70] from samp03svr
[19/01/2014 17:54:41] [debug] #1 000b3dd0 in public Timer1 () from rp.amx
[19/01/2014 17:54:41] [debug] Native backtrace:
[19/01/2014 17:54:41] [debug] #0 f6b2d31b in _ZN10StackTraceC1EPv () from plugins/crashdetect.so
[19/01/2014 17:54:41] [debug] #1 f6b277c2 in _ZN11CrashDetect20PrintNativeBacktraceERSoPv () from plugins/crashdetect.so
[19/01/2014 17:54:41] [debug] #2 f6b283ac in _ZN11CrashDetect20PrintNativeBacktraceEPv () from plugins/crashdetect.so
[19/01/2014 17:54:41] [debug] #3 f6b28856 in _ZN11CrashDetect11OnExceptionEPv () from plugins/crashdetect.so
[19/01/2014 17:54:41] [debug] #4 f6b2cf6c in ?? () from plugins/crashdetect.so
[19/01/2014 17:54:41] [debug] #5 f7721410 in ?? ()
[19/01/2014 17:54:41] [debug] #6 08082a26 in ?? () from samp03svr
[19/01/2014 17:54:41] [debug] #7 0807e4bc in ?? () from samp03svr
[19/01/2014 17:54:41] [debug] #8 0806fde9 in ?? () from samp03svr
[19/01/2014 17:54:41] [debug] #9 080d0ee3 in ?? () from samp03svr
[19/01/2014 17:54:41] [debug] #10 08093e44 in ?? () from samp03svr
[19/01/2014 17:54:41] [debug] #11 f6b2503c in _ZN11CrashDetect13DoAmxCallbackEiPiS0_ () from plugins/crashdetect.so
[19/01/2014 17:54:41] [debug] #12 f6b2b458 in ?? () from plugins/crashdetect.so
[19/01/2014 17:54:41] [debug] #13 f6b2fc61 in amx_Exec () from plugins/crashdetect.so
[19/01/2014 17:54:41] [debug] #14 f6b27708 in _ZN11CrashDetect9DoAmxExecEPii () from plugins/crashdetect.so
[19/01/2014 17:54:41] [debug] #15 f6b2b1c9 in ?? () from plugins/crashdetect.so
[19/01/2014 17:54:41] [debug] #16 080dc405 in ?? () from samp03svr
[19/01/2014 17:54:41] [debug] #17 080b5efb in ?? () from samp03svr
[19/01/2014 17:54:41] [debug] #18 080b16d3 in ?? () from samp03svr
[19/01/2014 17:54:41] [debug] #19 f747ee46 in __libc_start_main () from /lib32/libc.so.6
[19/01/2014 17:54:41] [debug] #20 0804b521 in ?? () from samp03svr
Pawn code:

PHP код:
public Timer1() //every second timer
{
    for(new 
i=0i<MAX_PLAYERSi++)
    {
        if(
IsPlayerConnected(i))
        {    
                  new 
dest[512],dest2[128];
                      
GetPlayerNetworkStats(i,dest,sizeof(dest));
                  new 
= (strfind(dest,"Bytes received: ",true) + 16);
                  
strmid(dest2,dest,f,strfind(dest,"Acks rece",true,f));
                  new 
bytes strval(dest2);
                  if(
bytes > (LastBytes[i]+20000)) WarningBytes[i]++;
                  if(
WarningBytes[i] > 3)
            {
                           
printf("[Attack 2] Player %d",i);
                
Kick(i);
                                             continue;
            }
            
LastBytes[i] = bytes;
                        }
      }

When I remove this code server had not crashed.

P.S. Sorry for my bad English.
Reply
#2

У самп-сторис тоже самое.
У некоторых серверов крашит сама функция GetPlayerNetworkStats из-за какого-то плагина на сколько я думаю.
Кстати я думал Евген тебе не паблик защиту а что нибудь нормальное дал.

Вот подарочеГ
PHP код:
forward CheckDoser();
public 
CheckDoser()
{
    new 
stats[500], idxposmsgs;
    foreach (new 
Player)
    {
        if(
IsPlayerNPC(i)) continue;
        
idx 0;
        
GetPlayerNetworkStats(istatssizeof(stats));
        
pos strfind(stats"Messages received: "true);
        
msgs strval(strtok(stats[pos+18], idx));
        if(
MessagesCount[i]+1000 msgs)
        {
            
printf("ID %d Dos",i);
            
Kick(i);
            continue;
        }
    }
    return 
1;

Reply
#3

It's most likely your code, try this:

pawn Код:
forward Timer1();
public Timer1() //every second timer
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            new
                dest[512],
                pos[2],
                bytes;

            GetPlayerNetworkStats(i,dest,sizeof(dest));

            if ((pos[0] = strfind(dest, "Bytes received", true) + 16) > 15)
            {
                if ((pos[1] = strfind(dest, "Acks rece", true)) == -1)
                    continue;
           
                dest[pos[1]] = '\0';
                bytes = strval(dest[pos[0]]);

                if (bytes > (LastBytes[i] + 20000))
                {
                    WarningBytes[i] ++;

                    if (WarningBytes[i] > 3)
                    {
                        printf("[Attack 2] Player %d",i);
                        Kick(i);
                        continue;
                    }
                }
                LastBytes[i] = bytes;
            }
        }
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)