fixed crash in cmd_set for NeonSpam
[NeonServV5.git] / src / mysqlConn.c
index ea3c2b89ab4d1042463438d4ce62d5ed97c2dd54..3e5dd19dfac03a156ede2bb49a30bfb26f83b5a7 100644 (file)
  */
 
 #include "mysqlConn.h"
-#define DATABASE_VERSION "14"
+#define DATABASE_VERSION "15"
 
 struct mysql_conn_struct {
-    unsigned long tid;
-    MYSQL *mysql_conn = NULL;
+    unsigned int tid;
+    MYSQL *mysql_conn;
     struct used_result *used_results;
     struct escaped_string *escaped_strings;
     struct mysql_conn_struct *next;
@@ -264,14 +264,19 @@ char* escape_string(const char *str) {
 struct mysql_conn_struct *get_mysql_conn_struct() {
     SYNCHRONIZE(synchronized);
     struct mysql_conn_struct *mysql_conn;
-    unsigned long tid = syscall(SYS_gettid);
+    unsigned int tid;
+    #ifdef HAVE_THREADS
+    tid = (unsigned int) pthread_self_tid();
+    #else
+    tid = 1;
+    #endif
     for(mysql_conn = mysql_conns; mysql_conn; mysql_conn = mysql_conn->next) {
         if(mysql_conn->tid == tid) {
             DESYNCHRONIZE(synchronized);
             return mysql_conn;
         }
     }
-    mysql_conn = malloc(*mysql_conn);
+    mysql_conn = malloc(sizeof(*mysql_conn));
     mysql_conn->mysql_conn = mysql_init(NULL);
     mysql_conn->tid = tid;
     mysql_conn->used_results = NULL;