Open Walter-Correa opened 8 years ago
I whipped up a short script opening, writing, closing, opening, reading single file multiple times:
#include <a_samp>
#define _inc_a_samp
stock File:log_fopen(const name[], filemode: mode = io_readwrite)
{
new File:handle = fopen(name, mode);
printf("Obtained handle %d", _:handle);
return handle;
}
#if defined _ALS_fopen
#undef fopen
#else
#define _ALS_fopen
#endif
#define fopen log_fopen
stock bool:log_fclose(File:handle)
{
new bool:result = fclose(handle);
printf("Closed handle %d with result %d", _:handle, _:result);
return result;
}
#if defined _ALS_fclose
#undef fclose
#else
#define _ALS_fclose
#endif
#define fclose log_fclose
#include <YSI\y_ini>
main () {}
new stock holder;
public OnGameModeInit()
{
for (new i = 0; i != 100000; ++i) {
new INI:File = INI_Open("test.ini");
INI_SetTag(File,"Data");
INI_WriteInt(File,"Value", random(10));
INI_Close(File);
if (!fexist("test.ini")) {
printf("Test failed after %d trials", i);
return 0;
}
INI_ParseFile("test.ini", "Load_%s", .bExtra = true, .extra = random(13));
}
return 1;
}
forward Load_Data(somevalue, name[], value[]);
public Load_Data(somevalue, name[], value[])
{
INI_Int("Value", holder);
return 1;
}
10k times works like a charm, but - I encourage you to run it on the server you have problems with, and check for like 100 iterations: if the problem happens, we can debug further.
Tho, for 100k iterations, I got some interesting things (excerpts):
Obtained handle 5134872
Closed handle 5134872 with result 1
Obtained handle 5134904
Closed handle 5134904 with result 1
Obtained handle 5134904
Closed handle 5134872 with result 1
Closed handle 5134904 with result 1
Double opening of the same file? Not good
On last iteration
Obtained handle 5134872
Closed handle 5134872 with result 1
[debug] Run time error 4: "Array index out of bounds"
[debug] AMX backtrace:
[debug] #0 00039b58 in INI_AddToBuffer (INI:file=0, key[]=@0005b674 "Value", value[]=@000082a8 "9") at D:\Dev\PAWN\ugrp\pawno\include\YSI\..\YSI_Storage\y_ini/writing.inc:772
[debug] #1 00038ee4 in INI_WriteInt (INI:file=0, name[]=@0005b674 "Value", data=9) at D:\Dev\PAWN\ugrp\pawno\include\YSI\..\YSI_Storage\y_ini/writing.inc:446
[debug] #2 0003b7d0 in public ScriptInit_OnGameModeInit () at yini.pwn:47
[debug] #3 000065d8 in public YVers_OnScriptInit () at D:\Dev\PAWN\ugrp\pawno\include\YSI\..\YSI_Storage\..\YSI_Internal\..\YSI_Server\y_scriptinit.inc:184
Not good either
Hello! I have the same problem: http://forum.sa-mp.com/showthread.php?t=454367
I need a solution if is a y_ini bug, because I love this include!
Thank you!