AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   plugin_end() & SQL_FreeHandle = WRONG (https://forums.alliedmods.net/showthread.php?t=121255)

waza123a 03-13-2010 13:59

plugin_end() & SQL_FreeHandle = WRONG
 
If you use plugin_end() with SQL_* then you will get random crash on map change. (Linux 100% , possible in win too)


Some docs:

Quote:

Native Overview
The basic natives of SQLX are:
  • SQL_FreeHandle - Frees a Handle. You must do this or else memory will leak.
    • Note that you should currently not call this native during plugin_end(). The backend threader freezes the query queue at this time and flushes all remaining queries back to the main thread. It is likely your plugin will simply deadlock (freeze idly). Even if this is corrected, there is no reason to use threaded queries in plugin_end() anyway, because all remaining threaded queries are executed as non-threaded before the mapchanges.


So, then there is a question, where to put

SQL_FreeHandle ?

When plugin starts, it's connecting to mysql and connection is alive until map change, then you need some how close mysql connection or you will got memory leak, so how to do it ?

Thanks.

Exolent[jNr] 03-13-2010 15:20

Re: plugin_end() & SQL_FreeHandle = WRONG
 
You could connect/disconnect each time you need to do a query.

waza123a 03-13-2010 16:11

Re: plugin_end() & SQL_FreeHandle = WRONG
 
i think this will be a bit slow if i have many sql querys in my script.

Need some how handle changelevel , and disconnect from mysql there, and after that server will change level.. but before plugin_end is called.

Seta00 03-13-2010 16:24

Re: plugin_end() & SQL_FreeHandle = WRONG
 
Then rearrange your logic.

Exolent[jNr] 03-13-2010 17:19

Re: plugin_end() & SQL_FreeHandle = WRONG
 
Then use threaded queries instead of normal queries.

Sylwester 03-13-2010 18:12

Re: plugin_end() & SQL_FreeHandle = WRONG
 
You need sql connection if you want to use SQL_QuoteString.

@waza123a: I'm using SQL_FreeHandle in plugin_end in my rpg mod (when you save player data by name) and it has never caused crash when I was testing it. See if you can crash your server with it. If you can't make it crash your server, then take a look at the way I coded it and maybe you will find a way to solve your problem.

Sn!ff3r 03-14-2010 01:42

Re: plugin_end() & SQL_FreeHandle = WRONG
 
@up - but server leaves opened mysql connections.


All times are GMT -4. The time now is 08:45.

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