Skip to content

Instantly share code, notes, and snippets.

@Habbie
Created February 22, 2019 00:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Habbie/92f0a5b389339c09d7d0931addf94329 to your computer and use it in GitHub Desktop.
Save Habbie/92f0a5b389339c09d7d0931addf94329 to your computer and use it in GitHub Desktop.
diff --git a/modules/gmysqlbackend/smysql.cc b/modules/gmysqlbackend/smysql.cc
index ce0e4196f..035c587dc 100644
--- a/modules/gmysqlbackend/smysql.cc
+++ b/modules/gmysqlbackend/smysql.cc
@@ -32,21 +32,32 @@
#include "pdns/namespaces.hh"
#include "pdns/lock.hh"
+#include <sys/types.h>
+
#if MYSQL_VERSION_ID >= 80000 && !defined(MARIADB_BASE_VERSION)
// Need to keep this for compatibility with MySQL < 8.0.0, which used typedef char my_bool;
// MariaDB up to 10.4 also always define it.
typedef bool my_bool;
#endif
+static int threadid(void) {
+ return pthread_self();
+}
+
class MySQLThreadCloser
{
public:
~MySQLThreadCloser() {
+ ostringstream s;
+ s<<threadid()<<" ~MySQLThreadCloser closing ... ";
if(d_enabled) {
+ s<<" mysql_thread_end()";
mysql_thread_end();
}
+ s<<endl;
+ cerr<<s.str();
}
- void enable() { d_enabled = true; }
+ void enable() { cerr<<threadid()<<" MySQLThreadCloser enabled"<<endl; d_enabled = true; }
private:
bool d_enabled = false;
@@ -488,6 +499,10 @@ SMySQL::SMySQL(const string &database, const string &host, uint16_t port, const
const string &password, const string &group, bool setIsolation, unsigned int timeout):
d_database(database), d_host(host), d_msocket(msocket), d_user(user), d_password(password), d_group(group), d_timeout(timeout), d_port(port), d_setIsolation(setIsolation)
{
+ ostringstream s;
+
+ s<<threadid()<<" SMySQL"<<endl;
+ cerr<<s.str();
connect();
}
@@ -498,6 +513,9 @@ void SMySQL::setLog(bool state)
SMySQL::~SMySQL()
{
+ ostringstream s;
+ s<<threadid()<<" ~SMySQL"<<endl;
+ cerr<<s.str();
mysql_close(&d_db);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment