Linux problem
#1

So server is shutting down all time and i got in console

Quote:

samp03svr: amx/amxfile.c:222: fputs_cell: Assertion `fp!=((void *)0)' failed.

I have set all scriptfiles chmod 777
Reply
#2

http://dracoblue.net/dev/amxamxfilec...-in-fputscell/
Reply
#3

But before few days i didnt have this problem, and then just randomly server started to shutdown. And i have set all directories writeable
Reply
#4

Dracoblue also mentioned to check if the file handle is valid when you open a file before using an invalid file handle in any some functions. For example if you use an invalid file handle in fread/fwrite/fclose, it can crash the server. Other than that, I don't know what could cause it.
Reply
#5

Is there some way to find which of those file handles is incorrect?
Reply
#6

Some files u uploaded might be corrupted, happedned to me but it got fixed when i uploaded a few files again
Reply
#7

You can prevent them through the scripts.

An example:
pawn Код:
new
    File: fhandle = fopen(...);

if (fhandle) // Valid file handle
{
    // code.. you can read from/write to the file
    fclose(fhandle);
}
Reply
#8

I have that

Quote:

LoadHouses() {

if(!fexist("apartments.cfg")) return 1;

new
szFileStr[1024],
File: iFileHandle = fopen("apartments.cfg", io_read),
iIndex;

while(iIndex < sizeof(HouseInfo) && fread(iFileHandle, szFileStr)) {
sscanf(szFileStr, "p<|>iiis[128]s[24]ffffffffiiiiiiiiiiiiiiiiiiffiiiiiiiiiii",

It started after i changed house config file.

Quote:

SaveHouses() {

new
szFileStr[1024],
File: fHandle = fopen("apartments.cfg", io_write);

for(new iIndex; iIndex < MAX_HOUSES; iIndex++) {
format(szFileStr, sizeof(szFileStr), "%d|%d|%d|%s|%s|%f|%f|%f|%f|%f|%f|%f|%f|%d|%d|%d|% d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%f|%f| %d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d\r\n",

Config line
Quote:

0|0|0||Nobody|0.000000|0.000000|-500.000000|0.000000|0.000000|0.000000|0.000000|0.0 00000|1|0|0|0|0|0|0|0|0|0|0|0|0|1|1582|1162|0|0|0. 000000|0.000000|0|0|0|0|0|0|0|0|0|0|0

Reply
#9

Valid file handle means if the file was opened successfully, not if it exists.

You haven't checked for both (even though in the SaveHouses you haven't posted the part that writes).

pawn Код:
LoadHouses()
{
    if(!fexist("apartments.cfg")) return 1;
   
    new
        szFileStr[1024],
        File: iFileHandle = fopen("apartments.cfg", io_read),
        iIndex;
   
    if (iFileHandle) // valid handle
    {
        while(iIndex < sizeof(HouseInfo) && fread(iFileHandle, szFileStr))
        {
            sscanf(...);
            // may some other code..
           
            iIndex++;
        }
        fclose(iFileHandle);
    }
    return 1;
}
pawn Код:
SaveHouses()
{
    new
        szFileStr[1024],
        File: fHandle = fopen("apartments.cfg", io_write);
   
    if (fHandle) // valid handle
    {
        for(new iIndex; iIndex < MAX_HOUSES; iIndex++)
        {
            format(...);
            fwrite(fHandle, szFileStr);
        }
        fclose(fHandle);
    }
    ...
    return 1;
}
Reply
#10

Still the same

Quote:

samp03svr: amx/amxfile.c:222: fputs_cell: Assertion `fp!=((void *)0)' failed.

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)