Jump to content

AsyncSQL Improved


Recommended Posts

  • Former Staff

M2 Download Center

This is the hidden content, please
( Internal )

 

I edited Async Class to use C++ Standard mutex and thread support

AsyncSQL.h

ASyncSQL.cpp

 

plus if you have this line in main.cpp inside the main function inside the db core source delete it 

DBManager.Quit();

this line will close MySQL connections  before making sure that all the queries are done (which may not save the last thing a player do before closing the server) plus it will dump a core file since the db core will abort without successful exit! 

 

#edited

  • Using std::gurad (which unlock the mutex when the object is destroyed) instead of manually lock and unlock mutex 
  • rewrote the Profiler class with std::chrono 

#Note : Don't  just copy and paste .. make a backup , test , then use it

Best regards.

  • Metin2 Dev 27
  • Good 8
  • Love 1
  • Love 9
Link to comment
Share on other sites

  • Honorable Member

AsyncSQL.h

This page is no longer available. It has either expired, been removed by its creator, or removed by one of the Pastebin staff.
 
Edited by martysama0134
wrong trailing garbage in the url
  • Metin2 Dev 13
  • Not Good 1
  • Think 2
  • Good 4
  • Love 5
Link to comment
Share on other sites

  • Former Staff
12 minutes ago, martysama0134 said:

AsyncSQL.h

This page is no longer available. It has either expired, been removed by its creator, or removed by one of the Pastebin staff.
 

sorry i edited the file after putting the link .. didn't thought that the link will change!
thanks for noticing 

Link to comment
Share on other sites

  • Silver

You can edit a little more, I think it will look better.

 

Use nullptr instead of NULL

Please stop usage header guards in 2019, go for pragma once

Use smart pointers instead of raw pointers

Use lock_guard instead of lock manually everytime

Clear dirty korean commands, unused veriables etc.

 

Anyway thanks for publishing.

  • Love 1
Link to comment
Share on other sites

  • Former Staff
15 minutes ago, Koray said:

You can edit a little more, I think it will look better.

 

Use nullptr instead of NULL

Please stop usage header guards in 2019, go for pragma once

Use smart pointers instead of raw pointers

Use lock_guard instead of lock manually everytime

Clear dirty korean commands, unused veriables etc.

 

Anyway thanks for publishing.

i'll rewrite the whole file today or tomorrow maximum .. i just wanted to see if actually someone want it ... 

Link to comment
Share on other sites

  • 4 weeks later...
  • Former Staff
3 hours ago, flatik said:

Thank you for your public!

I found an error!

 

Here's the picture of it

https://metin2.download/picture/x8DbNtV3Hh4K9d65ZyR3sVa7GPNrjZ8d/.png

show me real error message ... see if their is a ".core" file and back trace it 


 

1 hour ago, ReFresh said:

Which requirements are needed for use this AsyncSQL?

c++11 and above 

Edited by Metin2 Dev
Core X - External 2 Internal
  • Love 1
Link to comment
Share on other sites

  • 1 month later...
  • Premium

You should check if the thread is already joined, or just simply check if you already called Quit, cus db is crashing at the very end of the process, because quit is called from the db too (and also from the destructor of CAsyncSQL).
NpEVRji.png

5lM7g8a.png

Edited by Metin2 Dev
Core X - External 2 Internal
  • Sad 1

The one and only UI programming guideline

Link to comment
Share on other sites

  • Former Staff
17 hours ago, masodikbela said:

You should check if the thread is already joined, or just simply check if you already called Quit, cus db is crashing at the very end of the process, because quit is called from the db too (and also from the destructor of CAsyncSQL).
NpEVRji.png

5lM7g8a.png

i've already mentioned this in the post

 

Edited by Metin2 Dev
Core X - External 2 Internal
Link to comment
Share on other sites

  • 3 months later...
Le 09/03/2019 à 17:45, flatik a dit :

Thank you for your public!

I found an error!

 

Here's the picture of it

https://metin2.download/picture/x8DbNtV3Hh4K9d65ZyR3sVa7GPNrjZ8d/.png

m_pThread

Should be initialized in constructor to avoid undefined behavior, the constructor should look like this

CAsyncSQL::CAsyncSQL()
	: m_stHost(""), m_stUser(""), m_stPassword(""), m_stDB(""), m_stLocale(""),
	m_iMsgCount(0), m_iPort(0), m_bEnd(false),
	m_mtxQuery(), m_mtxResult(),
	m_iQueryFinished(0), m_ulThreadID(0), m_bConnected(false),
	m_iCopiedQuery(0),
	m_pThread(nullptr)
{
	memset(&m_hDB, 0, sizeof(m_hDB));

	m_aiPipe[0] = 0;
	m_aiPipe[1] = 0;
}

 

Edited by Metin2 Dev
Core X - External 2 Internal
  • Love 1
Link to comment
Share on other sites

  • 2 weeks later...
  • Former Staff
On 7/19/2019 at 12:51 AM, Trial said:

m_pThread

Should be initialized in constructor to avoid undefined behavior, the constructor should look like this


CAsyncSQL::CAsyncSQL()
	: m_stHost(""), m_stUser(""), m_stPassword(""), m_stDB(""), m_stLocale(""),
	m_iMsgCount(0), m_iPort(0), m_bEnd(false),
	m_mtxQuery(), m_mtxResult(),
	m_iQueryFinished(0), m_ulThreadID(0), m_bConnected(false),
	m_iCopiedQuery(0),
	m_pThread(nullptr)
{
	memset(&m_hDB, 0, sizeof(m_hDB));

	m_aiPipe[0] = 0;
	m_aiPipe[1] = 0;
}

 

this was the case but somehow it changed ...

 

Now it's updated !!

  • Love 1
Link to comment
Share on other sites

  • 1 year later...
  • 1 month later...
  • Premium
On 3/5/2021 at 8:30 AM, Shahin said:

 

Can anybody help me with this? image.png

 

I have a lot of conflicts with the SQLMsg struct

any ideas?

remove

typedef struct _SQLMsg SQLMsg;

in guild.h and include db.h

Edited by Metin2 Dev
Core X - External 2 Internal
Link to comment
Share on other sites

  • 3 months later...

88dacc3ce5.png

 

any idea? just remove? 

 

btw:

 

Real Server Log OffAsyncSQL: connected to localhost (reconnect 1) FATAL ERROR!! mysql client library was not compiled with thread safety failed, retrying in 5 seconds

 

? you have full source from libmysql? i cannot change the thread_safe option because its missing

Edited by Metin2 Dev
Core X - External 2 Internal
Link to comment
Share on other sites

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.