Skip to content

Commit

Permalink
Merge pull request #843 from satori/refactor_headers
Browse files Browse the repository at this point in the history
Refactor header includes.
  • Loading branch information
renecannao authored Dec 21, 2016
2 parents b118592 + 3665ba0 commit 32b412f
Show file tree
Hide file tree
Showing 52 changed files with 304 additions and 356 deletions.
6 changes: 4 additions & 2 deletions include/MySQL_Authentication.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#ifndef __CLASS_MYSQL_AUTHENTICATION_H
#define __CLASS_MYSQL_AUTHENTICATION_H

#include "proxysql.h"
#include "cpp.h"
#include <unordered_map>

#include "proxysql.h"
#include "proxysql_atomic.h"
#include "proxysql_mem.h"

typedef struct _account_details_t {
char *username;
Expand Down
5 changes: 2 additions & 3 deletions include/MySQL_Data_Stream.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#ifndef __CLASS_MYSQL_DATA_STREAM_H
#define __CLASS_MYSQL_DATA_STREAM_H

#include "proxysql.h"
#include "cpp.h"

#include "mysql_connection.h"
#include "proxysql_mem.h"

#define QUEUE_T_DEFAULT_SIZE 32768

Expand Down
5 changes: 2 additions & 3 deletions include/MySQL_HostGroups_Manager.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#ifndef __CLASS_MYSQL_HOSTGROUPS_MANAGER_H
#define __CLASS_MYSQL_HOSTGROUPS_MANAGER_H
#include "proxysql.h"
#include "cpp.h"

#include <cassert>
#include <thread>

#include "thread.h"
#include "gen_utils.h"
#include "wqueue.h"

/*
Expand Down
3 changes: 1 addition & 2 deletions include/MySQL_Logger.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#ifndef __CLASS_MYSQL_LOGGER_H
#define __CLASS_MYSQL_LOGGER_H
#include "proxysql.h"
#include "cpp.h"

#include "MySQL_Session.h"

class MySQL_Event {
private:
Expand Down
5 changes: 3 additions & 2 deletions include/MySQL_Monitor.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#ifndef __CLASS_MYSQL_MONITOR_H
#define __CLASS_MYSQL_MONITOR_H

#include "mysql_client.h"
#include "proxysql.h"
#include "cpp.h"
#include "thread.h"
#include "sqlite3db.h"
#include "wqueue.h"


Expand Down
6 changes: 5 additions & 1 deletion include/MySQL_PreparedStatement.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#ifndef CLASS_MYSQL_PREPARED_STATEMENT_H
#define CLASS_MYSQL_PREPARED_STATEMENT_H

#include <map>
#include <stack>

#include "mysql_client.h"
#include "proxysql.h"
#include "cpp.h"
#include "proxysql_atomic.h"

/*
One of the main challenge in handling prepared statement (PS) is that a single
Expand Down
3 changes: 2 additions & 1 deletion include/MySQL_Protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#define __CLASS_MYSQL_PROTOCOL_H

#include "proxysql.h"
#include "cpp.h"

#include "MySQL_PreparedStatement.h"

#define RESULTSET_BUFLEN 16300

Expand Down
6 changes: 5 additions & 1 deletion include/MySQL_Session.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#ifndef __CLASS_MYSQL_SESSION_H
#define __CLASS_MYSQL_SESSION_H
#include "proxysql.h"
#include "cpp.h"

#include "mysql_backend.h"
#include "proxysql_admin.h"
#include "query_processor.h"


// these structs will be used for various regex hardcoded
// their initial use will be for sql_log_bin , sql_mode and time_zone
Expand Down
8 changes: 6 additions & 2 deletions include/MySQL_Thread.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
#ifndef __CLASS_MYSQL_THREAD_H
#define __CLASS_MYSQL_THREAD_H
#define ____CLASS_STANDARD_MYSQL_THREAD_H
#include "proxysql.h"
#include "cpp.h"

#include <poll.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
Expand Down
2 changes: 2 additions & 0 deletions include/StatCounters.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef __CLASS_STAT_COUNTERS_H
#define __CLASS_STAT_COUNTERS_H

#include "proxysql_atomic.h"

class StatCounters {
private:
bool with_lock;
Expand Down
2 changes: 2 additions & 0 deletions include/configfile.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef __CLASS_PROXYSQL_CONFIGFILE_H
#define __CLASS_PROXYSQL_CONFIGFILE_H

#include <sys/stat.h>

#include "libconfig.h++"

using namespace libconfig;
Expand Down
25 changes: 0 additions & 25 deletions include/cpp.h

This file was deleted.

6 changes: 4 additions & 2 deletions include/fileutils.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include <unistd.h>

#ifndef __CLASS_FILEUTILS_H
#define __CLASS_FILEUTILS_H

#include <unistd.h>

class FileUtils {
public:
static bool isReadable(const char *pathname) {
Expand All @@ -13,4 +14,5 @@ class FileUtils {
return false;
};
};

#endif /* __CLASS_FILEUTILS_H */
1 change: 1 addition & 0 deletions include/gen_utils.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#ifndef __CLASS_PTR_ARRAY_H
#define __CLASS_PTR_ARRAY_H

#include "proxysql.h"

#define MIN_ARRAY_LEN 8
Expand Down
3 changes: 1 addition & 2 deletions include/mysql_backend.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#ifndef __CLASS_MYSQL_BACKEND_H
#define __CLASS_MYSQL_BACKEND_H
#include "proxysql.h"
#include "cpp.h"

#include "MySQL_Data_Stream.h"

class MySQL_Backend
{
Expand Down
8 changes: 8 additions & 0 deletions include/mysql_client.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#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__
4 changes: 2 additions & 2 deletions include/mysql_connection.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef __CLASS_MYSQL_CONNECTION_H
#define __CLASS_MYSQL_CONNECTION_H

#include "proxysql.h"
#include "cpp.h"
#include "MySQL_HostGroups_Manager.h"
#include "MySQL_Protocol.h"

#define STATUS_MYSQL_CONNECTION_TRANSACTION 0x00000001
#define STATUS_MYSQL_CONNECTION_COMPRESSION 0x00000002
Expand Down
10 changes: 10 additions & 0 deletions include/network.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#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__
76 changes: 3 additions & 73 deletions include/proxysql.h
Original file line number Diff line number Diff line change
@@ -1,66 +1,12 @@
#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>
#ifndef PROXYSQL_H__
#define PROXYSQL_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
Expand All @@ -70,10 +16,6 @@
#define VALGRIND_DISABLE_ERROR_REPORTING
#endif /* DEBUG */

#include "sqlite3.h"

#include "c_tokenizer.h"

#ifdef DEBUG
#define DEB "_DEBUG"
#else
Expand All @@ -85,13 +27,6 @@
#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 *);

Expand All @@ -100,16 +35,11 @@ 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__
4 changes: 2 additions & 2 deletions include/proxysql_admin.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef __CLASS_PROXYSQL_ADMIN_H
#define __CLASS_PROXYSQL_ADMIN_H

#include "proxysql.h"
#include "cpp.h"
#include <vector>
#include "sqlite3db.h"

typedef struct { uint32_t hash; uint32_t key; } t_symstruct;

Expand Down
7 changes: 5 additions & 2 deletions include/proxysql_atomic.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#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)

Expand Down
16 changes: 7 additions & 9 deletions include/proxysql_debug.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
#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
Expand Down Expand Up @@ -108,3 +105,4 @@ extern int gdbg;
#ifdef DEBUG
//void *debug_logger();
#endif
#endif //PROXYSQL_DEBUG_H__
Loading

0 comments on commit 32b412f

Please sign in to comment.