SA-MP Forums Archive
fopen returns invalid handle after long server uptime - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: fopen returns invalid handle after long server uptime (/showthread.php?tid=560565)



fopen returns invalid handle after long server uptime - SiripIkan - 29.01.2015

So, my server (Linux VPS) has a problem with fopen. After long time since server started (about 6 hours uptime or more), fopen starts to return invalid handle on every file even they all exist. This method:

pawn Код:
new File:open = fopen("(FILE NAME HERE)", io_write); //same thing happens on all filemode
    if(open)
    {
        //File operation here
        fclose(open);
    }
Just keeps the server running with fopen not functioning until server restarts.

This problem made players data keep reset until I changed the saving system to SQLite. Even i've changed it, this problem still exists. And now the INSERT and UPDATE Query doesn't work after long time along with invalid fopen handle. it really frustating me D:

Can someone help me? thanks before.
Okay sorry for my bad English.


Solved
Quote:
Originally Posted by SiripIkan
Посмотреть сообщение
Have checked it with FileEx Include and noticed a file handle doesn't get closed after being opened. This file always called when OnPlayerConnect() triggers.
After closing this file handle now the problem is gone.

Thanks all for helping, especially for Vince..



Re: fopen returns invalid handle after long server uptime - ATGOggy - 29.01.2015

Linux is case sensitive so, "scriptfiles" and "Scriptfiles" is different in Linux.


Re: fopen returns invalid handle after long server uptime - RedFusion - 29.01.2015

I've had this problem with linux hosts aswell, still no clue why it happens..


Re: fopen returns invalid handle after long server uptime - SiripIkan - 30.01.2015

Bump..

Quote:
Originally Posted by ATGOggy
Посмотреть сообщение
Linux is case sensitive so, "scriptfiles" and "Scriptfiles" is different in Linux.
the case is fine, file can be opened (with fopen) without problems but after long time it always return invalid handle until server restarts.


Re: fopen returns invalid handle after long server uptime - Vince - 30.01.2015

Are you closing the files properly when you don't need them anymore? This is pure speculation, but it might just refuse to open any more files while any previous ones aren't properly closed.


Re: fopen returns invalid handle after long server uptime - SiripIkan - 30.01.2015

Quote:
Originally Posted by RedFusion
Посмотреть сообщение
I've had this problem with linux hosts aswell, still no clue why it happens..
What do you do when it happens?

Quote:
Originally Posted by Vince
Посмотреть сообщение
Are you closing the files properly when you don't need them anymore? This is pure speculation, but it might just refuse to open any more files while any previous ones aren't properly closed.
Yes, i've checked all of my script. All file handles closed after being opened.


Re: fopen returns invalid handle after long server uptime - RedFusion - 30.01.2015

Quote:
Originally Posted by SiripIkan
Посмотреть сообщение
What do you do when it happens?


Yes, i've checked all of my script. All file handles closed after being opened.
Nothing special at all, it works just fine on all of the windows hosts i ever used. And i do close all of the valid file handles.


Re: fopen returns invalid handle after long server uptime - SiripIkan - 31.01.2015

Bump..

Quote:
Originally Posted by RedFusion
Посмотреть сообщение
Nothing special at all, it works just fine on all of the windows hosts i ever used. And i do close all of the valid file handles.
Hmm.. that's strange :/


Re: fopen returns invalid handle after long server uptime - DRIFT_HUNTER - 31.01.2015

Since its a host, it may have limited read/write quotas...


Re: fopen returns invalid handle after long server uptime - SiripIkan - 31.01.2015

Quote:
Originally Posted by DRIFT_HUNTER
Посмотреть сообщение
Since its a host, it may have limited read/write quotas...
It could be the problem... But how to check it?