Revert "Refactor header includes."

pull/849/head
René Cannaò 9 years ago committed by GitHub
parent 32b412f87f
commit a6c53d0d12

@ -1,11 +1,9 @@
#ifndef __CLASS_MYSQL_AUTHENTICATION_H
#define __CLASS_MYSQL_AUTHENTICATION_H
#include <unordered_map>
#include "proxysql.h"
#include "proxysql_atomic.h"
#include "proxysql_mem.h"
#include "cpp.h"
typedef struct _account_details_t {
char *username;

@ -1,8 +1,9 @@
#ifndef __CLASS_MYSQL_DATA_STREAM_H
#define __CLASS_MYSQL_DATA_STREAM_H
#include "mysql_connection.h"
#include "proxysql_mem.h"
#include "proxysql.h"
#include "cpp.h"
#define QUEUE_T_DEFAULT_SIZE 32768

@ -1,10 +1,11 @@
#ifndef __CLASS_MYSQL_HOSTGROUPS_MANAGER_H
#define __CLASS_MYSQL_HOSTGROUPS_MANAGER_H
#include "proxysql.h"
#include "cpp.h"
#include <cassert>
#include <thread>
#include "gen_utils.h"
#include "thread.h"
#include "wqueue.h"
/*

@ -1,7 +1,8 @@
#ifndef __CLASS_MYSQL_LOGGER_H
#define __CLASS_MYSQL_LOGGER_H
#include "proxysql.h"
#include "cpp.h"
#include "MySQL_Session.h"
class MySQL_Event {
private:

@ -1,9 +1,8 @@
#ifndef __CLASS_MYSQL_MONITOR_H
#define __CLASS_MYSQL_MONITOR_H
#include "mysql_client.h"
#include "proxysql.h"
#include "sqlite3db.h"
#include "cpp.h"
#include "thread.h"
#include "wqueue.h"

@ -1,12 +1,8 @@
#ifndef CLASS_MYSQL_PREPARED_STATEMENT_H
#define CLASS_MYSQL_PREPARED_STATEMENT_H
#include <map>
#include <stack>
#include "mysql_client.h"
#include "proxysql.h"
#include "proxysql_atomic.h"
#include "cpp.h"
/*
One of the main challenge in handling prepared statement (PS) is that a single

@ -2,8 +2,7 @@
#define __CLASS_MYSQL_PROTOCOL_H
#include "proxysql.h"
#include "MySQL_PreparedStatement.h"
#include "cpp.h"
#define RESULTSET_BUFLEN 16300

@ -1,11 +1,7 @@
#ifndef __CLASS_MYSQL_SESSION_H
#define __CLASS_MYSQL_SESSION_H
#include "proxysql.h"
#include "mysql_backend.h"
#include "proxysql_admin.h"
#include "query_processor.h"
#include "cpp.h"
// these structs will be used for various regex hardcoded
// their initial use will be for sql_log_bin , sql_mode and time_zone

@ -1,14 +1,10 @@
#ifndef __CLASS_MYSQL_THREAD_H
#define __CLASS_MYSQL_THREAD_H
#define ____CLASS_STANDARD_MYSQL_THREAD_H
#include <poll.h>
#include "proxysql.h"
#include "cpp.h"
#include <sys/epoll.h>
#include "MySQL_Data_Stream.h"
#include "StatCounters.h"
#define CACHE_LINE_SIZE 64
#define MIN_POLL_LEN 8
#define MIN_POLL_DELETE_RATIO 8
#define MY_EPOLL_THREAD_MAXEVENTS 128

@ -1,8 +1,6 @@
#ifndef __CLASS_STAT_COUNTERS_H
#define __CLASS_STAT_COUNTERS_H
#include "proxysql_atomic.h"
class StatCounters {
private:
bool with_lock;

@ -1,8 +1,6 @@
#ifndef __CLASS_PROXYSQL_CONFIGFILE_H
#define __CLASS_PROXYSQL_CONFIGFILE_H
#include <sys/stat.h>
#include "libconfig.h++"
using namespace libconfig;

@ -0,0 +1,25 @@
#include "gen_utils.h"
#include "MySQL_Thread.h"
#include "MySQL_Session.h"
#include "mysql_backend.h"
#include "MySQL_Data_Stream.h"
#include "query_cache.hpp"
#include "mysql_connection.h"
#include "sqlite3db.h"
#include "StatCounters.h"
#include "MySQL_Monitor.hpp"
#include "MySQL_Protocol.h"
#include "MySQL_Authentication.hpp"
#include "fileutils.hpp"
#include "configfile.hpp"
#include "query_processor.h"
#include "proxysql_admin.h"
#include "MySQL_HostGroups_Manager.h"
#include "MySQL_Logger.hpp"
#include "MySQL_PreparedStatement.h"
#undef swap
#undef min
#undef max
#include <stdio.h>
#include <map>
#include <unordered_map>

@ -1,8 +1,7 @@
#ifndef __CLASS_FILEUTILS_H
#define __CLASS_FILEUTILS_H
#include <unistd.h>
#ifndef __CLASS_FILEUTILS_H
#define __CLASS_FILEUTILS_H
class FileUtils {
public:
static bool isReadable(const char *pathname) {
@ -14,5 +13,4 @@ class FileUtils {
return false;
};
};
#endif /* __CLASS_FILEUTILS_H */

@ -1,6 +1,5 @@
#ifndef __CLASS_PTR_ARRAY_H
#define __CLASS_PTR_ARRAY_H
#include "proxysql.h"
#define MIN_ARRAY_LEN 8

@ -1,7 +1,8 @@
#ifndef __CLASS_MYSQL_BACKEND_H
#define __CLASS_MYSQL_BACKEND_H
#include "proxysql.h"
#include "cpp.h"
#include "MySQL_Data_Stream.h"
class MySQL_Backend
{

@ -1,8 +0,0 @@
#ifndef PROXYSQL_MYSQL_CLIENT_H__
#define PROXYSQL_MYSQL_CLIENT_H__
#define HAVE_BOOL
#include "mysql.h"
#undef max_allowed_packet
#endif // PROXYSQL_MYSQL_CLIENT_H__

@ -1,8 +1,8 @@
#ifndef __CLASS_MYSQL_CONNECTION_H
#define __CLASS_MYSQL_CONNECTION_H
#include "MySQL_HostGroups_Manager.h"
#include "MySQL_Protocol.h"
#include "proxysql.h"
#include "cpp.h"
#define STATUS_MYSQL_CONNECTION_TRANSACTION 0x00000001
#define STATUS_MYSQL_CONNECTION_COMPRESSION 0x00000002

@ -1,10 +0,0 @@
#ifndef PROXYSQL_NETWORK_H__
#define PROXYSQL_NETWORK_H__
#include <cstdint>
int listen_on_port(char *ip, uint16_t port, int backlog, bool reuseport=false);
int listen_on_unix(char *, int);
int connect_socket(char *, int);
#endif // PROXYSQL_NETWORK_H__

@ -1,12 +1,66 @@
#ifndef PROXYSQL_H__
#define PROXYSQL_H__
#ifdef __cplusplus
#include <string>
#include <stack>
#include <algorithm>
#ifndef EZOPTION
#define EZOPTION
#endif /* EZOPTION */
#endif
#include <search.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <time.h>
#include <string.h>
#ifdef NDEBUG
#undef NDEBUG
#endif
#include <assert.h>
#include <unistd.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <pthread.h>
#include <sys/wait.h>
#include <netinet/in.h>
#include <sys/un.h>
#include <netinet/tcp.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <netdb.h>
#include <sys/syscall.h>
#include <sys/stat.h>
#include <signal.h>
#include <errno.h>
#include <ctype.h>
#include <openssl/sha.h>
#include <openssl/md5.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include <poll.h>
#include <execinfo.h>
#include <dlfcn.h>
#include <sys/ioctl.h>
#define HAVE_BOOL
#include "my_global.h"
#include "my_pthread.h"
#include "mysql.h"
#include "proxysql_mem.h"
#include "proxysql_structs.h"
#include "proxysql_debug.h"
#include "proxysql_macros.h"
#include "jemalloc.h"
#ifdef DEBUG
//#define VALGRIND_ENABLE_ERROR_REPORTING
//#define VALGRIND_DISABLE_ERROR_REPORTING
@ -16,6 +70,10 @@
#define VALGRIND_DISABLE_ERROR_REPORTING
#endif /* DEBUG */
#include "sqlite3.h"
#include "c_tokenizer.h"
#ifdef DEBUG
#define DEB "_DEBUG"
#else
@ -27,6 +85,13 @@
#ifndef PROXYSQL_FUNC_DEFS
#define PROXYSQL_FUNC_DEFS
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
int listen_on_port(char *ip, uint16_t port, int backlog, bool reuseport=false);
int listen_on_unix(char *, int);
int connect_socket(char *, int);
int config_file_is_readable(char *);
unsigned int CPY3(unsigned char *);
@ -35,11 +100,16 @@ int pkt_end(unsigned char *, unsigned int);
int pkt_com_query(unsigned char *, unsigned int);
enum MySQL_response_type mysql_response(unsigned char *, unsigned int);
void proxy_error_func(const char *, ...);
#ifdef DEBUG
void init_debug_struct();
void init_debug_struct_from_cmdline();
void proxy_debug_func(enum debug_module, int, int, const char *, int, const char *, const char *, ...);
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* PROXYSQL_FUNC_DEFS */
#endif // PROXYSQL_H__

@ -1,8 +1,8 @@
#ifndef __CLASS_PROXYSQL_ADMIN_H
#define __CLASS_PROXYSQL_ADMIN_H
#include "proxysql.h"
#include "sqlite3db.h"
#include "cpp.h"
#include <vector>
typedef struct { uint32_t hash; uint32_t key; } t_symstruct;

@ -1,16 +1,13 @@
#ifndef PROXYSQL_ATOMIC
#define PROXYSQL_ATOMIC
#include <cstring>
#include <unistd.h>
/*
typedef unsigned spinlock;
typedef struct _rwlock_t rwlock_t;
struct _rwlock_t {
spinlock lock;
unsigned readers;
};
*/
#define atomic_inc(P) __sync_add_and_fetch((P), 1)
#define atomic_dec(P) __sync_add_and_fetch((P), -1)

@ -1,10 +1,13 @@
#ifndef PROXYSQL_DEBUG_H__
#define PROXYSQL_DEBUG_H__
#include <ctime>
void proxy_error_func(const char *, ...);
/*
#ifdef DEBUG
#ifndef DEBUG_EXTERN
#define DEBUG_EXTERN
extern debug_level *gdbg_lvl;
extern int gdbg;
#endif
#endif
*/
#ifdef DEBUG
#define PROXY_TRACE() { proxy_debug(PROXY_DEBUG_GENERIC,10,"TRACE\n"); }
#else
@ -105,4 +108,3 @@ void proxy_error_func(const char *, ...);
#ifdef DEBUG
//void *debug_logger();
#endif
#endif //PROXYSQL_DEBUG_H__

@ -1,11 +1,11 @@
#ifndef __CLASS_PROXYSQL_GLOVARS_H
#define __CLASS_PROXYSQL_GLOVARS_H
#include <openssl/ssl.h>
#include "configfile.hpp"
namespace ez { class ezOptionParser; }
namespace ez {
class ezOptionParser;
};
class ProxySQL_GlobalVariables {
public:

@ -0,0 +1,32 @@
/*
Use of generic memory structure
set/get function defined by the user
Ex:
*/
typedef _hte_ext_t hte_ext_t;
union _hte_ext_t {
void *ptr;
int i;
uint32_t u32;
uint64_t u64;
};
struct __leo_hash_entry_t {
unsigned char *key;
void *self;
hte_ext_t ext0;
hte_ext_t ext1;
hte_ext_t ext2;
hte_ext_t ext3;
hte_ext_t ext4;
hte_ext_t ext5;
hte_ext_t ext6;
hte_ext_t ext7;
hte_ext_t ext8;
hte_ext_t ext9;
};

@ -1,7 +1,3 @@
#ifndef PROXYSQL_MACROS_H__
#define PROXYSQL_MACROS_H__
#include <sys/ioctl.h>
#define strdup_null(__c) ( __c ? strdup(__c) : __c )
#define char_malloc (char *)malloc
@ -62,5 +58,3 @@
uint32_t *a=(uint32_t *)x; \
*a=*((uint32_t *)y); \
} while(0)
#endif // PROXYSQL_MACROS_H__

@ -1,6 +1,3 @@
#ifndef PROXYSQL_MEM_H__
#define PROXYSQL_MEM_H__
#define L_SFC_MIN_ELEM_SIZE 8
#define L_SFC_MID_ELEM_SIZE 128
#define L_SFC_MAX_ELEM_SIZE 2048
@ -92,4 +89,3 @@ static inline char * l_strdup(const char *s) {
#endif /* L_STACK */
#endif // PROXYSQL_MEM_H__

@ -1,15 +1,11 @@
#ifndef PROXYSQL_STRUCTS_H__
#define PROXYSQL_STRUCTS_H__
#include <cstdint>
#include <ctime>
#include <pthread.h>
#include <unistd.h>
#define PKT_PARSED 0
#define PKT_ERROR 1
#ifdef max_allowed_packet
#undef max_allowed_packet
#endif
#ifndef PROXYSQL_ENUMS
#define PROXYSQL_ENUMS
@ -312,7 +308,11 @@ typedef struct _mysql_data_stream_t mysql_data_stream_t;
typedef struct _mysql_session_t mysql_session_t;
typedef struct _bytes_stats_t bytes_stats_t;
typedef struct _mysql_hdr mysql_hdr;
typedef int (*PKT_HANDLER)(uint8_t *pkt, uint32_t len);
typedef int (*PKT_HANDLER)(u_char *pkt, u_int len);
typedef struct __fdb_hash_t fdb_hash_t;
typedef struct __fdb_hash_entry fdb_hash_entry;
typedef unsigned spinlock;
typedef struct _rwlock_t rwlock_t;
typedef struct _PtrSize_t PtrSize_t;
typedef struct _proxysql_mysql_thread_t proxysql_mysql_thread_t;
typedef struct { char * table_name; char * table_def; } table_def_t;
@ -374,12 +374,37 @@ struct _debug_level {
};
#endif /* DEBUG */
struct _rwlock_t {
spinlock lock;
unsigned readers;
};
// counters for number of bytes received and sent
struct _bytes_stats_t {
uint64_t bytes_recv;
uint64_t bytes_sent;
};
struct __fdb_hash_t {
rwlock_t lock;
uint64_t dataSize;
uint64_t purgeChunkSize;
uint64_t purgeIdx;
};
struct __fdb_hash_entry {
unsigned char *key;
unsigned char *value;
fdb_hash_t *hash;
struct __fdb_hash_entry *self;
uint32_t klen;
uint32_t length;
time_t expire;
time_t access;
uint32_t ref_count;
};
#define MAX_EVENTS_PER_STATE 15
struct mysql_protocol_events {
PKT_HANDLER ha[MAX_EVENTS_PER_STATE];
@ -408,7 +433,7 @@ struct _global_variable_entry_t {
// structure that defines mysql protocol header
struct _mysql_hdr {
uint32_t pkt_length:24, pkt_id:8;
u_int pkt_length:24, pkt_id:8;
};
struct _proxysql_mysql_thread_t {
@ -534,11 +559,19 @@ struct _mysql_session_t {
#include "proxysql_glovars.hpp"
//#endif
#ifndef GLOBAL_DEFINED
#define GLOBAL_DEFINED
EXTERN global_variables glovars;
#endif /* GLOBAL_DEFINED */
//#ifdef __cplusplus
#ifndef GLOVARS
#define GLOVARS
//#include "proxysql_glovars.hpp"
#endif
//#endif
#ifdef PROXYSQL_EXTERN
#ifndef GLOBAL_DEFINED_OPTS_ENTRIES
#define GLOBAL_DEFINED_OPTS_ENTRIES
@ -723,4 +756,5 @@ extern __thread bool mysql_thread___session_debug;
extern __thread unsigned int g_seed;
#endif /* PROXYSQL_EXTERN */
#endif // PROXYSQL_STRUCTS_H__

@ -1,11 +1,7 @@
#ifndef __CLASS_QUERY_CACHE_H
#define __CLASS_QUERY_CACHE_H
#include <cstdint>
#include <pthread.h>
#include "sqlite3db.h"
#include "proxysql.h"
#include "cpp.h"
#define EXPIRE_DROPIT 0
#define SHARED_QUERY_CACHE_HASH_TABLES 32

@ -1,11 +1,7 @@
#ifndef __CLASS_QUERY_PROCESSOR_H
#define __CLASS_QUERY_PROCESSOR_H
#include <unordered_map>
#include <vector>
#include "MySQL_PreparedStatement.h"
#include "proxysql_mem.h"
#include "proxysql.h"
#include "cpp.h"
typedef std::unordered_map<std::uint64_t, void *> umap_query_digest;

@ -1,13 +1,8 @@
#ifndef __CLASS_SQLITE3DB_H
#define __CLASS_SQLITE3DB_H
#include "proxysql.h"
#include "cpp.h"
#include <cstdlib>
#include <cstring>
#include <vector>
#include "sqlite3.h"
#include "proxysql_atomic.h"
class SQLite3_row {
public:

@ -1,6 +1,6 @@
#include "MySQL_Authentication.hpp"
#include "gen_utils.h"
#include "btree_map.h"
#include "proxysql.h"
#include "cpp.h"
#include "proxysql_atomic.h"
#include "SpookyV2.h"

@ -1,12 +1,12 @@
#include "MySQL_HostGroups_Manager.h"
#include "MySQL_Thread.h"
#include "proxysql_admin.h"
#include "proxysql_debug.h"
#include "proxysql.h"
#include "cpp.h"
#define char_malloc (char *)malloc
#define itostr(__s, __i) { __s=char_malloc(32); sprintf(__s, "%lld", __i); }
#include "thread.h"
#include "wqueue.h"
#define SAFE_SQLITE3_STEP(_stmt) do {\
do {\
rc=sqlite3_step(_stmt);\

@ -1,12 +1,8 @@
#include "MySQL_Logger.hpp"
#include <fstream>
#include "proxysql.h"
#include "cpp.h"
#include <dirent.h>
#include "MySQL_Session.h"
#include "MySQL_Thread.h"
#include "proxysql_debug.h"
static uint8_t mysql_encode_length(uint64_t len, unsigned char *hd) {
if (len < 251) return 1;

@ -1,12 +1,21 @@
#include "MySQL_Monitor.hpp"
/*
RECENT CHANGELOG
1.2.0723
* almost completely rewritten
* use of blocking call for new connections
* use of Thread Pool instead of a thread per check type
0.2.0902
* original implementation
*/
#include <map>
#include <mutex>
#include <thread>
#include "proxysql.h"
#include "cpp.h"
#include <fcntl.h>
#include <sys/socket.h>
#include "MySQL_Thread.h"
#include "proxysql_admin.h"
#include "proxysql_debug.h"
#include "thread.h"
#include "wqueue.h"
#ifdef DEBUG
#define DEB "_DEBUG"
@ -1389,6 +1398,7 @@ __monitor_run:
}
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setstacksize (&attr, 64*1024);
pthread_t monitor_connect_thread;
pthread_create(&monitor_connect_thread, &attr, &monitor_connect_pthread,NULL);
pthread_t monitor_ping_thread;

@ -1,10 +1,7 @@
#include "MySQL_PreparedStatement.h"
#include "proxysql.h"
#include "cpp.h"
#include <cassert>
#include "gen_utils.h"
#include "SpookyV2.h"
#include "proxysql_debug.h"
extern MySQL_STMT_Manager *GloMyStmt;

@ -1,15 +1,16 @@
#include "MySQL_Protocol.h"
#include <openssl/rand.h>
#include "MySQL_Authentication.hpp"
#include "MySQL_Session.h"
#include "MySQL_Thread.h"
#include "proxysql_debug.h"
#include "proxysql.h"
#include "cpp.h"
extern MySQL_Authentication *GloMyAuth;
extern MySQL_Threads_Handler *GloMTH;
#ifdef max_allowed_packet
#undef max_allowed_packet
#endif
//#define RESULTSET_BUFLEN 16300
#ifdef DEBUG
static void __dump_pkt(const char *func, unsigned char *_ptr, unsigned int len) {
@ -72,7 +73,7 @@ static inline int write_encoded_length_and_string(unsigned char *p, uint64_t val
return l+val;
}
void proxy_compute_sha1_hash_multi(uint8_t *digest, const uint8_t *buf1, int len1, const char *buf2, int len2) {
void proxy_compute_sha1_hash_multi(uint8 *digest, const uint8_t *buf1, int len1, const char *buf2, int len2) {
PROXY_TRACE();
SHA_CTX sha1_context;
@ -82,7 +83,7 @@ void proxy_compute_sha1_hash_multi(uint8_t *digest, const uint8_t *buf1, int len
SHA1_Final(digest, &sha1_context);
}
void proxy_compute_sha1_hash(uint8_t *digest, const char *buf, int len) {
void proxy_compute_sha1_hash(uint8 *digest, const char *buf, int len) {
PROXY_TRACE();
SHA_CTX sha1_context;
@ -91,13 +92,13 @@ void proxy_compute_sha1_hash(uint8_t *digest, const char *buf, int len) {
SHA1_Final(digest, &sha1_context);
}
void proxy_compute_two_stage_sha1_hash(const char *password, size_t pass_len, uint8_t *hash_stage1, uint8_t *hash_stage2) {
void proxy_compute_two_stage_sha1_hash(const char *password, size_t pass_len, uint8 *hash_stage1, uint8 *hash_stage2) {
proxy_compute_sha1_hash(hash_stage1, password, pass_len);
proxy_compute_sha1_hash(hash_stage2, (const char *) hash_stage1, SHA_DIGEST_LENGTH);
}
void proxy_my_crypt(char *to, const uint8_t *s1, const uint8_t *s2, uint len) {
const uint8_t *s1_end= s1 + len;
void proxy_my_crypt(char *to, const uchar *s1, const uchar *s2, uint len) {
const uint8 *s1_end= s1 + len;
while (s1 < s1_end)
*to++= *s1++ ^ *s2++;
}
@ -131,23 +132,23 @@ void unhex_pass(uint8_t *out, const char *in) {
void proxy_scramble(char *to, const uint8_t *message, const char *password)
{
uint8_t hash_stage1[SHA_DIGEST_LENGTH];
uint8_t hash_stage2[SHA_DIGEST_LENGTH];
uint8 hash_stage1[SHA_DIGEST_LENGTH];
uint8 hash_stage2[SHA_DIGEST_LENGTH];
proxy_compute_two_stage_sha1_hash(password, strlen(password), hash_stage1, hash_stage2);
proxy_compute_sha1_hash_multi((uint8_t *) to, message, SCRAMBLE_LENGTH, (const char *) hash_stage2, SHA_DIGEST_LENGTH);
proxy_my_crypt(to, (const uint8_t *) to, hash_stage1, SCRAMBLE_LENGTH);
proxy_compute_sha1_hash_multi((uint8 *) to, message, SCRAMBLE_LENGTH, (const char *) hash_stage2, SHA_DIGEST_LENGTH);
proxy_my_crypt(to, (const uchar *) to, hash_stage1, SCRAMBLE_LENGTH);
return;
}
bool proxy_scramble_sha1(char *pass_reply, const uint8_t *message, const char *sha1_sha1_pass, char *sha1_pass) {
bool ret=false;
uint8_t hash_stage1[SHA_DIGEST_LENGTH];
uint8_t hash_stage2[SHA_DIGEST_LENGTH];
uint8_t hash_stage3[SHA_DIGEST_LENGTH];
uint8_t to[SHA_DIGEST_LENGTH];
uint8 hash_stage1[SHA_DIGEST_LENGTH];
uint8 hash_stage2[SHA_DIGEST_LENGTH];
uint8 hash_stage3[SHA_DIGEST_LENGTH];
uint8 to[SHA_DIGEST_LENGTH];
unhex_pass(hash_stage2,sha1_sha1_pass);
proxy_compute_sha1_hash_multi((uint8_t *) to, message, SCRAMBLE_LENGTH, (const char *) hash_stage2, SHA_DIGEST_LENGTH);
proxy_my_crypt((char *)hash_stage1,(const uint8_t *) pass_reply, to, SCRAMBLE_LENGTH);
proxy_compute_sha1_hash_multi((uint8 *) to, message, SCRAMBLE_LENGTH, (const char *) hash_stage2, SHA_DIGEST_LENGTH);
proxy_my_crypt((char *)hash_stage1,(const uchar *) pass_reply, to, SCRAMBLE_LENGTH);
proxy_compute_sha1_hash(hash_stage3, (const char *) hash_stage1, SHA_DIGEST_LENGTH);
if (memcmp(hash_stage2,hash_stage3,SHA_DIGEST_LENGTH)==0) {
memcpy(sha1_pass,hash_stage1,SHA_DIGEST_LENGTH);

@ -1,16 +1,7 @@
#include "MySQL_Session.h"
#include <arpa/inet.h>
#include <netinet/in.h>
#include <openssl/err.h>
#include "MySQL_Authentication.hpp"
#include "MySQL_Logger.hpp"
#include "MySQL_Thread.h"
#include "proxysql_debug.h"
#include "query_cache.hpp"
#include "proxysql.h"
#include "cpp.h"
#include "re2/re2.h"
#include "re2/regexp.h"
#include "SpookyV2.h"
#define SELECT_VERSION_COMMENT "select @@version_comment limit 1"
@ -752,6 +743,7 @@ void MySQL_Session::handler_again___new_thread_to_kill_connection() {
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
pthread_attr_setstacksize (&attr, 256*1024);
pthread_t pt;
pthread_create(&pt, &attr, &kill_query_thread, ka);
}

@ -1,16 +1,9 @@
//#define __CLASS_STANDARD_MYSQL_THREAD_H
#define MYSQL_THREAD_IMPLEMENTATION
#include "proxysql.h"
#include "cpp.h"
#include "MySQL_Thread.h"
#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/tcp.h>
#include "c_tokenizer.h"
#include "MySQL_Logger.hpp"
#include "MySQL_Monitor.hpp"
#include "network.h"
#include "proxysql_debug.h"
#ifdef DEBUG
MySQL_Session *sess_stopat;
#endif
@ -1687,6 +1680,8 @@ void MySQL_Threads_Handler::init(unsigned int num, size_t stack) {
} else {
if (num_threads==0) num_threads=DEFAULT_NUM_THREADS; //default
}
int rc=pthread_attr_setstacksize(&attr, stacksize);
assert(rc==0);
mysql_threads=(proxysql_mysql_thread_t *)malloc(sizeof(proxysql_mysql_thread_t)*num_threads);
mysql_threads_idles=(proxysql_mysql_thread_t *)malloc(sizeof(proxysql_mysql_thread_t)*num_threads);
}
@ -2480,7 +2475,7 @@ bool MySQL_Thread::process_data_on_data_stream(MySQL_Data_Stream *myds, unsigned
}
if (myds->active==false) {
if (myds->active==FALSE) {
if (myds->sess->client_myds==myds) {
proxy_debug(PROXY_DEBUG_NET,1, "Session=%p, DataStream=%p -- Deleting FD %d\n", myds->sess, myds, myds->fd);
myds->sess->set_unhealthy();

@ -1,19 +1,25 @@
#include "proxysql_admin.h"
#include <fcntl.h>
#include <netinet/in.h>
#include <sys/wait.h>
#include "jemalloc.h"
#include <iostream> // std::cout
#include <algorithm> // std::sort
#include <vector> // std::vector
#include "re2/re2.h"
#include "c_tokenizer.h"
#include "MySQL_Authentication.hpp"
#include "MySQL_Logger.hpp"
#include "MySQL_Thread.h"
#include "network.h"
#include "proxysql_debug.h"
#include "query_cache.hpp"
#include "re2/regexp.h"
#include "proxysql.h"
#include "cpp.h"
#include <search.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/time.h>
#include <time.h>
#include <string.h>
#include <assert.h>
#include <unistd.h>
#include <sys/socket.h>
#include <resolv.h>
#include <arpa/inet.h>
#include <pthread.h>
#include "SpookyV2.h"
//#define MYSQL_THREAD_IMPLEMENTATION
#define SELECT_VERSION_COMMENT "select @@version_comment limit 1"
#define SELECT_VERSION_COMMENT_LEN 32
@ -2188,6 +2194,7 @@ static void * admin_main_loop(void *arg)
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
pthread_attr_setstacksize (&attr, mystacksize);
if(GloVars.global.nostart) {
nostart_=true;
@ -2390,6 +2397,7 @@ bool ProxySQL_Admin::init() {
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setstacksize (&attr, mystacksize);
admindb=new SQLite3DB();
admindb->open((char *)"file:mem_admindb?mode=memory&cache=shared", SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_FULLMUTEX);
@ -3728,8 +3736,8 @@ void ProxySQL_Admin::__add_active_users(enum cred_username_type usertype) {
if (r->fields[1][0]=='*') { // the password is already hashed
password=strdup(r->fields[1]);
} else { // we must hash it
uint8_t hash_stage1[SHA_DIGEST_LENGTH];
uint8_t hash_stage2[SHA_DIGEST_LENGTH];
uint8 hash_stage1[SHA_DIGEST_LENGTH];
uint8 hash_stage2[SHA_DIGEST_LENGTH];
SHA_CTX sha1_context;
SHA1_Init(&sha1_context);
SHA1_Update(&sha1_context, r->fields[1], strlen(r->fields[1]));
@ -5012,6 +5020,7 @@ unsigned long long ProxySQL_External_Scheduler::run_once() {
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
pthread_attr_setstacksize (&attr, 64*1024);
pid_t *cpid_ptr=(pid_t *)malloc(sizeof(pid_t));
*cpid_ptr=cpid;
pthread_t thr;

@ -1,12 +1,8 @@
#include "proxysql_glovars.hpp"
#include <csignal>
#include <execinfo.h>
#include <unistd.h>
#include "ezOptionParser.hpp"
#include "proxysql_debug.h"
#include "gen_utils.h"
#include "proxysql.h"
#include "cpp.h"
#include <string>
static void term_handler(int sig) {

@ -1,9 +1,9 @@
#include "query_cache.hpp"
#include "btree_map.h"
#include "MySQL_Thread.h"
#include "proxysql.h"
#include "cpp.h"
#include "query_cache.hpp"
#include "proxysql_atomic.h"
#include "SpookyV2.h"
#include "proxysql_debug.h"
#define THR_UPDATE_CNT(__a, __b, __c, __d) \
do {\

@ -1,17 +1,14 @@
#include "query_processor.h"
#include <climits>
#include "pcrecpp.h"
#include <iostream> // std::cout
#include <algorithm> // std::sort
#include <vector> // std::vector
#include "re2/re2.h"
#include "re2/regexp.h"
#include "proxysql.h"
#include "cpp.h"
#include "c_tokenizer.h"
#include "proxysql_debug.h"
#include "MySQL_Session.h"
#include "MySQL_Thread.h"
#include "SpookyV2.h"
#include "pcrecpp.h"
#ifdef DEBUG
#define DEB "_DEBUG"

@ -1,10 +1,14 @@
#include "configfile.hpp"
#include "proxysql.h"
#include "cpp.h"
#include <cassert>
#include <cstring>
#include <iostream>
#include "fileutils.hpp"
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <libconfig.h++>
using namespace std;
using namespace libconfig;

@ -1,11 +1,6 @@
#include "proxysql_debug.h"
#include <cstdio>
#include <cstdarg>
#include <cxxabi.h>
#include "proxysql.h"
#include "proxysql_atomic.h"
#include <cxxabi.h>
#ifdef DEBUG

@ -1,6 +1,6 @@
#include "gen_utils.h"
#include "proxysql.h"
#include "cpp.h"
#include "proxysql_mem.h"
char *escape_string_single_quotes(char *input, bool free_it) {
int i,j,l;

@ -1,7 +1,5 @@
#include "mysql_backend.h"
#include "MySQL_Session.h"
#include "MySQL_Thread.h"
#include "proxysql.h"
#include "cpp.h"
void * MySQL_Backend::operator new(size_t size) {
return l_alloc(size);

@ -1,12 +1,6 @@
#include "mysql_connection.h"
#include <fcntl.h>
#include <sys/socket.h>
#include "MySQL_Session.h"
#include "MySQL_Thread.h"
#include "proxysql.h"
#include "cpp.h"
#include "SpookyV2.h"
#include "proxysql_debug.h"
extern const CHARSET_INFO * proxysql_find_charset_nr(unsigned int nr);

@ -1,18 +1,6 @@
#include "MySQL_Data_Stream.h"
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/un.h>
#include "proxysql.h"
#include "cpp.h"
#include <zlib.h>
#include "MySQL_Session.h"
#include "MySQL_Thread.h"
#include "proxysql_debug.h"
#ifndef UNIX_PATH_MAX
#define UNIX_PATH_MAX 108
#endif
@ -125,7 +113,7 @@ MySQL_Data_Stream::MySQL_Data_Stream() {
queue_init(queueIN,QUEUE_T_DEFAULT_SIZE);
queue_init(queueOUT,QUEUE_T_DEFAULT_SIZE);
mybe=NULL;
active=true;
active=TRUE;
mypolls=NULL;
myconn=NULL; // 20141011
DSS=STATE_NOT_CONNECTED;
@ -257,7 +245,7 @@ void MySQL_Data_Stream::init(enum MySQL_DS_type _type, MySQL_Session *_sess, int
// TODO: should check the status of the data stream, and identify if it is safe to reconnect or if the session should be destroyed
void MySQL_Data_Stream::shut_soft() {
proxy_debug(PROXY_DEBUG_NET, 4, "Shutdown soft fd=%d. Session=%p, DataStream=%p\n", fd, sess, this);
active=false;
active=FALSE;
set_net_failure();
//if (sess) sess->net_failure=1;
}
@ -375,7 +363,7 @@ void MySQL_Data_Stream::set_pollout() {
int MySQL_Data_Stream::write_to_net_poll() {
int rc=0;
if (active==false) return rc;
if (active==FALSE) return rc;
proxy_debug(PROXY_DEBUG_NET,1,"Session=%p, DataStream=%p --\n", sess, this);
if (queue_data(queueOUT)) {
if ((sess->admin==false)) {

@ -1,18 +1,4 @@
#include "network.h"
#include <cerrno>
#include <cstdio>
#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/un.h>
#include <unistd.h>
#include "proxysql_debug.h"
#include "proxysql.h"
/*
* create a socket and listen on a specified IP and port

@ -1,10 +1,5 @@
#include "sqlite3db.h"
#include <cassert>
#include "proxysql.h"
#include "proxysql_atomic.h"
#include "proxysql_debug.h"
#include "cpp.h"
#include "SpookyV2.h"
#define USLEEP_SQLITE_LOCKED 100

@ -1,6 +1,11 @@
#include <iostream>
#include <thread>
#include "btree_map.h"
#include "proxysql.h"
//#define PROXYSQL_EXTERN
#include "cpp.h"
#include <sys/wait.h>
#include <libdaemon/dfork.h>
#include <libdaemon/dsignal.h>
@ -8,16 +13,6 @@
#include <libdaemon/dpid.h>
#include <libdaemon/dexec.h>
#include "gen_utils.h"
#include "MySQL_Authentication.hpp"
#include "MySQL_Monitor.hpp"
#include "MySQL_Thread.h"
#include "MySQL_Logger.hpp"
#include "proxysql_admin.h"
#include "proxysql_debug.h"
#include "query_cache.hpp"
#include "query_processor.h"
// MariaDB client library redefines dlerror(), see https://mariadb.atlassian.net/browse/CONC-101
#ifdef dlerror
#undef dlerror
@ -787,3 +782,4 @@ finish:
// l_mem_destroy(__thr_sfp);
return 0;
}

@ -1,2 +1,5 @@
#define PROXYSQL_EXTERN
#include "proxysql.h"
//#include "proxysql_glovars.hpp"
#include "cpp.h"
//ProxySQL_GlobalVariables GloVars;

Loading…
Cancel
Save