Jump to content

AsyncSQL Improved


Recommended Posts

  • Former Staff

M2 Download Center

Hidden Content

    Give reaction to this post to see the hidden content.
( Internal )

 

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

Hidden Content

    Give reaction to this post to see the hidden content.

Hidden Content

    Give reaction to this post to see the hidden content.

 

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 5
  • Love 6
  • Love 1
  • Good 4
Link to comment
  • Former Staff
12 minutes ago, martysama0134 said:

Hidden Content

    Give reaction to this post to see the hidden content.

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

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
  • 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
  • 4 weeks later...
  • VIP

Thank you for your public!

I found an error!

 

Here's the picture of it

Hidden Content

    Give reaction to this post to see the hidden content.

  • Metin2 Dev 2

c++latest, latest libs...

Link to comment
  • Former Staff
3 hours ago, flatik said:

Thank you for your public!

I found an error!

 

Here's the picture of it

Hidden Content

    Give reaction to this post to see the hidden content.

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 

  • Love 1
Link to comment
  • 1 month later...
  • 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

 

Link to comment
  • 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

Hidden Content

    Give reaction to this post to see the hidden content.

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;
}

 

  • Love 1
Link to comment
  • 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
  • 1 year later...

 

Can anybody help me with this? image.png

 

I have a lot of conflicts with the SQLMsg struct

any ideas?

Edited by Shahin
Link to comment
  • 1 month later...
On 3/5/2021 at 8:30 AM, Shahin said:

 

Can anybody help me with this? 

Hidden Content

    Give reaction to this post to see the hidden content.

 

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 xXIntelXx
Link to comment
  • 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 Mafuyu
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • 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.