Raised This Month: $ Target: $400
 0% 

plugin_end() & SQL_FreeHandle = WRONG


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
waza123a
Member
Join Date: Mar 2010
Old 03-13-2010 , 13:59   plugin_end() & SQL_FreeHandle = WRONG
Reply With Quote #1

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.
waza123a is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 03-13-2010 , 15:20   Re: plugin_end() & SQL_FreeHandle = WRONG
Reply With Quote #2

You could connect/disconnect each time you need to do a query.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
waza123a
Member
Join Date: Mar 2010
Old 03-13-2010 , 16:11   Re: plugin_end() & SQL_FreeHandle = WRONG
Reply With Quote #3

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.

Last edited by waza123a; 03-13-2010 at 16:23.
waza123a is offline
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 03-13-2010 , 16:24   Re: plugin_end() & SQL_FreeHandle = WRONG
Reply With Quote #4

Then rearrange your logic.
Seta00 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 03-13-2010 , 17:19   Re: plugin_end() & SQL_FreeHandle = WRONG
Reply With Quote #5

Then use threaded queries instead of normal queries.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Old 03-13-2010, 17:23
Seta00
This message has been deleted by Seta00. Reason: nvm
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 03-13-2010 , 18:12   Re: plugin_end() & SQL_FreeHandle = WRONG
Reply With Quote #6

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.
__________________
Impossible is Nothing

Last edited by Sylwester; 03-13-2010 at 18:14.
Sylwester is offline
Sn!ff3r
Veteran Member
Join Date: Aug 2007
Location: Poland
Old 03-14-2010 , 01:42   Re: plugin_end() & SQL_FreeHandle = WRONG
Reply With Quote #7

@up - but server leaves opened mysql connections.
__________________
Join US - custom Zombie Server - Custom Addons:



Sn!ff3r is offline
Send a message via Skype™ to Sn!ff3r
Reply


Thread Tools
Display Modes

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 08:45.


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