projects
/
NeonServV5.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
added "all" argument to cmd_invitemeall to get invited to all channels (not only...
[NeonServV5.git]
/
src
/
mysqlConn.c
diff --git
a/src/mysqlConn.c
b/src/mysqlConn.c
index 12ab76d6ff709ab7bf986e08384a62beaaef80bd..79c82e9d4194f49514cf14aa8202d4461fc63312 100644
(file)
--- a/
src/mysqlConn.c
+++ b/
src/mysqlConn.c
@@
-1,4
+1,4
@@
-/* mysqlConn.c - NeonServ v5.
3
+/* mysqlConn.c - NeonServ v5.
6
* Copyright (C) 2011-2012 Philipp Kreil (pk910)
*
* This program is free software: you can redistribute it and/or modify
* Copyright (C) 2011-2012 Philipp Kreil (pk910)
*
* This program is free software: you can redistribute it and/or modify
@@
-16,10
+16,12
@@
*/
#include "mysqlConn.h"
*/
#include "mysqlConn.h"
-#define DATABASE_VERSION "15"
+#define DATABASE_VERSION "20"
+
+static void show_mysql_error();
struct mysql_conn_struct {
struct mysql_conn_struct {
- unsigned
long
tid;
+ unsigned
int
tid;
MYSQL *mysql_conn;
struct used_result *used_results;
struct escaped_string *escaped_strings;
MYSQL *mysql_conn;
struct used_result *used_results;
struct escaped_string *escaped_strings;
@@
-46,7
+48,7
@@
static char *mysql_host, *mysql_user, *mysql_pass, *mysql_base;
static pthread_mutex_t synchronized;
#endif
static pthread_mutex_t synchronized;
#endif
-void check_mysql() {
+
static
void check_mysql() {
MYSQL *mysql_conn = get_mysql_conn();
int errid;
if((errid = mysql_ping(mysql_conn))) {
MYSQL *mysql_conn = get_mysql_conn();
int errid;
if((errid = mysql_ping(mysql_conn))) {
@@
-114,7
+116,6
@@
void init_mysql(char *host, int port, char *user, char *pass, char *base) {
version = atoi(row[0]);
}
}
version = atoi(row[0]);
}
}
- printf("%d \n", version);
if(!version) {
//CREATE DATABASE
FILE *f = fopen("database.sql", "r");
if(!version) {
//CREATE DATABASE
FILE *f = fopen("database.sql", "r");
@@
-201,10
+202,10
@@
void free_mysql() {
mysql_conns = NULL;
}
mysql_conns = NULL;
}
-void show_mysql_error() {
+
static
void show_mysql_error() {
MYSQL *mysql_conn = get_mysql_conn();
//show mysql_error()
MYSQL *mysql_conn = get_mysql_conn();
//show mysql_error()
- p
rintf(
"MySQL Error: %s\n", mysql_error(mysql_conn));
+ p
utlog(LOGLEVEL_ERROR,
"MySQL Error: %s\n", mysql_error(mysql_conn));
}
void printf_mysql_query(const char *text, ...) {
}
void printf_mysql_query(const char *text, ...) {
@@
-218,7
+219,7
@@
void printf_mysql_query(const char *text, ...) {
va_end(arg_list);
if (pos < 0 || pos > (MYSQLMAXLEN - 2)) pos = MYSQLMAXLEN - 2;
queryBuf[pos] = '\0';
va_end(arg_list);
if (pos < 0 || pos > (MYSQLMAXLEN - 2)) pos = MYSQLMAXLEN - 2;
queryBuf[pos] = '\0';
- p
rintf(
"MySQL: %s\n", queryBuf);
+ p
utlog(LOGLEVEL_MYSQL,
"MySQL: %s\n", queryBuf);
if(mysql_query(mysql_conn, queryBuf)) {
check_mysql();
if(mysql_query(mysql_conn, queryBuf)) {
if(mysql_query(mysql_conn, queryBuf)) {
check_mysql();
if(mysql_query(mysql_conn, queryBuf)) {
@@
-238,7
+239,7
@@
void printf_long_mysql_query(int len, const char *text, ...) {
va_end(arg_list);
if (pos < 0 || pos > (len - 2)) pos = len - 2;
queryBuf[pos] = '\0';
va_end(arg_list);
if (pos < 0 || pos > (len - 2)) pos = len - 2;
queryBuf[pos] = '\0';
- p
rintf(
"MySQL: %s\n", queryBuf);
+ p
utlog(LOGLEVEL_MYSQL,
"MySQL: %s\n", queryBuf);
if(mysql_query(mysql_conn, queryBuf)) {
check_mysql();
if(mysql_query(mysql_conn, queryBuf)) {
if(mysql_query(mysql_conn, queryBuf)) {
check_mysql();
if(mysql_query(mysql_conn, queryBuf)) {
@@
-264,9
+265,9
@@
char* escape_string(const char *str) {
struct mysql_conn_struct *get_mysql_conn_struct() {
SYNCHRONIZE(synchronized);
struct mysql_conn_struct *mysql_conn;
struct mysql_conn_struct *get_mysql_conn_struct() {
SYNCHRONIZE(synchronized);
struct mysql_conn_struct *mysql_conn;
- unsigned
long
tid;
+ unsigned
int
tid;
#ifdef HAVE_THREADS
#ifdef HAVE_THREADS
- tid =
syscall(SYS_gettid
);
+ tid =
(unsigned int) pthread_self_tid(
);
#else
tid = 1;
#endif
#else
tid = 1;
#endif