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

Server Clean Up (1.2.2)


Post New Thread Reply   
 
Thread Tools Display Modes
Jamster
Veteran Member
Join Date: Jun 2008
Old 05-02-2013 , 12:30   Re: Server Clean Up (1.2.1)
Reply With Quote #161

Right, new version up for securely checking it now, many thanks! D:

Last edited by Jamster; 05-02-2013 at 12:30.
Jamster is offline
Hurrican
Member
Join Date: Feb 2013
Old 05-05-2013 , 10:01   Re: Server Clean Up (1.2.1)
Reply With Quote #162

Spoiler


Hm? Cleanup Time too long?
__________________

Hurrican is offline
Jamster
Veteran Member
Join Date: Jun 2008
Old 05-05-2013 , 10:49   Re: Server Clean Up (1.2.1)
Reply With Quote #163

whoa damn, what version are you running and what game?
Jamster is offline
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 05-05-2013 , 11:58   Re: Server Clean Up (1.2.1)
Reply With Quote #164

Quote:
Originally Posted by Jamster View Post
whoa damn, what version are you running and what game?
At a glance it looks like you should close handles much more frequently than you currently are. In most instances you are running a for-loop or while-loop with an OpenDirectory function inside, yet only closing the handle on the final iteration.

I've edited your CleanServer function, removing any superfluous code for this example, leaving only while/for loops, OpenDirectories and any comments on where you should CloseHandle (and set to INVALID_HANDLE).

As a small addendum you can safely change all instances of Format in your original code to FormatEx for a little extra speed.

PHP Code:
CleanServer(const type)
{
    if (
type == RPY)
    {
        for (new 
i=0;i<=2;i++)
        {
            if (
DirExists(dir))
            {
                
h_dir OpenDirectory(dir);
                
                
//Should CloseHandle(h_dir) and h_dir = INVALID_HANDLE here
            
}
        }
    }
    else if (
type == SPR)
    {
        if (
DirExists(dir))
        {
            
h_dir OpenDirectory(dir);
            
            
//Should CloseHandle(h_dir) and h_dir = INVALID_HANDLE here
        
}
        
        if (
DirExists(dir))
        {
            
h_dir OpenDirectory(dir);
            
            while (
ReadDirEntry(h_dirsubdirsizeof(subdir)))
            {
                if (
DirExists(fullpath))
                {
                    
h_subdir OpenDirectory(fullpath);
                    
                    
//Should CloseHandle(h_subdir) and h_subdir = INVALID_HANDLE here
                
}
            }
            
            if (
h_subdir != INVALID_HANDLE)
                
CloseHandle(h_subdir); //Remove this
            
            //I'd recommend closing h_dir here, instead of at the end of the function.
            //CloseHandle(h_dir) and h_dir = INVALID_HANDLE here
        
}
    }
    else
    {
        if (
DirExists(dir))
        {
            
h_dir OpenDirectory(dir);
            
            
//I'd recommend closing h_dir here, instead of at the end of the function.
            //CloseHandle(h_dir) and h_dir = INVALID_HANDLE here
        
}
    }
    
    if (
h_dir != INVALID_HANDLE)
        
CloseHandle(h_dir); //Remove if you placed all other recommended CloseHandles
    
return true;

__________________

Last edited by 11530; 05-05-2013 at 12:01.
11530 is offline
Jamster
Veteran Member
Join Date: Jun 2008
Old 05-05-2013 , 12:57   Re: Server Clean Up (1.2.1)
Reply With Quote #165

Got you, thanks, I figured replacing the handle had the function of closing and replacing but I Guessed Wrong.
Jamster is offline
Jamster
Veteran Member
Join Date: Jun 2008
Old 05-05-2013 , 15:15   Re: Server Clean Up (1.2.2)
Reply With Quote #166

Right, new version posted, many thanks 11530, you saved me a lot of time there, I'm extremely grateful!
Jamster is offline
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 05-05-2013 , 15:31   Re: Server Clean Up (1.2.2)
Reply With Quote #167

Quote:
Originally Posted by Jamster View Post
Right, new version posted, many thanks 11530, you saved me a lot of time there, I'm extremely grateful!
You're very welcome. :)
__________________
11530 is offline
404UserNotFound
BANNED
Join Date: Dec 2011
Old 06-16-2013 , 15:15   Re: Server Clean Up (1.2.2)
Reply With Quote #168

Oh beauty, this is perfect! I've got my own dedi and I want to keep as much hard disk space open as possible, so having something like this to run in the background will be perfect, helping keep the tf/logs folder clean.

EDIT: Oh shit this deals with uploaded sprays too? I love you Jamster.

Last edited by 404UserNotFound; 06-16-2013 at 15:19.
404UserNotFound is offline
fluxX
SourceMod Donor
Join Date: May 2011
Location: Austria
Old 06-16-2013 , 16:08   Re: Server Clean Up (1.2.2)
Reply With Quote #169

Hi,

sprays don't get deleted here.. got sprays that are one month old.
config:
Spoiler

debug (those are older as 48 hours but there are still in the folder):
Spoiler

log:
Spoiler


Greetz
__________________
WCFAN Gameserver Community
fluxX is offline
Jamster
Veteran Member
Join Date: Jun 2008
Old 06-16-2013 , 17:13   Re: Server Clean Up (1.2.2)
Reply With Quote #170

Sprays are done by last accessed, in other words if a spray is popular and the player never changed it then it won't get deleted (well, until someone hasn't seen it for 48 hours, if you check the file you'll probably see it's one of your regular players sprays or something).

edit: I should maybe make that more clear in the config D:

Last edited by Jamster; 06-16-2013 at 17:33.
Jamster is offline
Reply



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 21:11.


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