summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorunknown <serg@serg.mysql.com>2001-07-02 21:52:22 +0200
committerunknown <serg@serg.mysql.com>2001-07-02 21:52:22 +0200
commita1826b55198ebd1ea5a3bafb88a52d1cf0c2f427 (patch)
treeb02cd20fcbc632447cd4b10782204969c9e6af34 /include
parent2d28c646cbd53c1fcdf800dc408580aa5377f3b9 (diff)
parentcdfc04fb0819109ba3f7b78e87191b9b8311b9bf (diff)
downloadmariadb-git-a1826b55198ebd1ea5a3bafb88a52d1cf0c2f427.tar.gz
merged
include/my_base.h: Auto merged include/myisam.h: Auto merged myisam/mi_open.c: Auto merged myisam/myisamdef.h: Auto merged myisam/myisampack.c: Auto merged mysql-test/t/alter_table.test: Auto merged mysys/tree.c: Auto merged sql/ha_myisam.cc: Auto merged sql/item_sum.cc: Auto merged sql/mysqld.cc: Auto merged sql/sql_table.cc: Auto merged
Diffstat (limited to 'include')
-rw-r--r--include/errmsg.h7
-rw-r--r--include/m_string.h13
-rw-r--r--include/my_base.h1
-rw-r--r--include/my_sys.h23
-rw-r--r--include/myisam.h2
-rw-r--r--include/mysql.h72
-rw-r--r--include/mysql_com.h17
-rw-r--r--include/mysqld_error.h10
-rw-r--r--include/mysys_err.h5
-rw-r--r--include/vio.h278
-rw-r--r--include/violite.h166
11 files changed, 278 insertions, 316 deletions
diff --git a/include/errmsg.h b/include/errmsg.h
index 12a3ee5557a..427174ffa53 100644
--- a/include/errmsg.h
+++ b/include/errmsg.h
@@ -54,3 +54,10 @@ extern const char *client_errors[]; /* Error messages */
#define CR_CANT_READ_CHARSET 2019
#define CR_NET_PACKET_TOO_LARGE 2020
#define CR_EMBEDDED_CONNECTION 2021
+#define CR_PROBE_SLAVE_STATUS 2022
+#define CR_PROBE_SLAVE_HOSTS 2023
+#define CR_PROBE_SLAVE_CONNECT 2024
+#define CR_PROBE_MASTER_CONNECT 2025
+
+
+
diff --git a/include/m_string.h b/include/m_string.h
index ce5197f17af..84c42e0c8b9 100644
--- a/include/m_string.h
+++ b/include/m_string.h
@@ -69,10 +69,6 @@
# define memmove(d, s, n) bmove((d), (s), (n)) /* our bmove */
#endif
-#if defined(HAVE_STPCPY) && !defined(HAVE_mit_thread)
-#define strmov(A,B) stpcpy((A),(B))
-#endif
-
/* Unixware 7 */
#if !defined(HAVE_BFILL)
# define bfill(A,B,C) memset((A),(C),(B))
@@ -90,6 +86,13 @@
extern "C" {
#endif
+#if defined(HAVE_STPCPY) && !defined(HAVE_mit_thread)
+#define strmov(A,B) stpcpy((A),(B))
+#ifndef stpcpy
+extern char *stpcpy(char *, const char *); /* For AIX with gcc 2.95.3 */
+#endif
+#endif
+
extern char NEAR _dig_vec[]; /* Declared in int2str() */
#ifdef BAD_STRING_COMPILER
@@ -148,7 +151,7 @@ extern void bchange(char *dst,uint old_len,const char *src,
uint new_len,uint tot_len);
extern void strappend(char *s,uint len,pchar fill);
extern char *strend(const char *s);
-extern char *strcend(const char *, pchar);
+extern char *strcend(const char *, pchar);
extern char *strfield(char *src,int fields,int chars,int blanks,
int tabch);
extern char *strfill(my_string s,uint len,pchar fill);
diff --git a/include/my_base.h b/include/my_base.h
index 7e63b72c934..f1d6c005262 100644
--- a/include/my_base.h
+++ b/include/my_base.h
@@ -215,6 +215,7 @@ enum ha_base_keytype {
#define HA_ERR_CRASHED_ON_USAGE 145 /* Table must be repaired */
#define HA_ERR_LOCK_WAIT_TIMEOUT 146
#define HA_ERR_LOCK_TABLE_FULL 147
+#define HA_ERR_READ_ONLY_TRANSACTION 148 /* Updates not allowed */
/* Other constants */
diff --git a/include/my_sys.h b/include/my_sys.h
index b5d59d2e801..c492262d925 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -62,6 +62,8 @@ extern int NEAR my_errno; /* Last error in mysys */
#define MY_DONT_CHECK_FILESIZE 128 /* Option to init_io_cache() */
#define MY_LINK_WARNING 32 /* my_redel() gives warning if links */
#define MY_COPYTIME 64 /* my_redel() copys time */
+#define MY_DELETE_OLD 256 /* my_create_with_symlink() */
+#define MY_RESOLVE_LINK 128 /* my_realpath(); Only resolve links */
#define MY_HOLD_ORIGINAL_MODES 128 /* my_copy() holds to file modes */
#define MY_REDEL_MAKE_BACKUP 256
#define MY_SEEK_NOT_DONE 32 /* my_lock may have to do a seek */
@@ -108,10 +110,7 @@ extern int NEAR my_errno; /* Last error in mysys */
/* root_alloc flags */
#define MY_KEEP_PREALLOC 1
-#define MY_MARK_BLOCKS_FREE 2 /* do not my_free() blocks,
- just move used into free list
- and mark all blocks as fully free
- */
+#define MY_MARK_BLOCKS_FREE 2 /* move used to free list and reuse them */
/* defines when allocating data */
@@ -210,7 +209,7 @@ extern long lCurMemory,lMaxMemory; /* from safemalloc */
extern ulong my_default_record_cache_size;
extern my_bool NEAR my_disable_locking,NEAR my_disable_async_io,
- NEAR my_disable_flush_key_blocks;
+ NEAR my_disable_flush_key_blocks, NEAR my_disable_symlinks;
extern char wild_many,wild_one,wild_prefix;
extern const char *charsets_dir;
extern char *defaults_extra_file;
@@ -382,6 +381,14 @@ extern File my_create(const char *FileName,int CreateFlags,
int AccsesFlags, myf MyFlags);
extern int my_close(File Filedes,myf MyFlags);
extern int my_mkdir(const char *dir, int Flags, myf MyFlags);
+extern int my_readlink(char *to, const char *filename, myf MyFlags);
+extern int my_realpath(char *to, const char *filename, myf MyFlags);
+extern File my_create_with_symlink(const char *linkname, const char *filename,
+ int createflags, int access_flags,
+ myf MyFlags);
+extern int my_delete_with_symlink(const char *name, myf MyFlags);
+extern int my_rename_with_symlink(const char *from,const char *to,myf MyFlags);
+extern int my_symlink(const char *content, const char *linkname, myf MyFlags);
extern uint my_read(File Filedes,byte *Buffer,uint Count,myf MyFlags);
extern uint my_pread(File Filedes,byte *Buffer,uint Count,my_off_t offset,
myf MyFlags);
@@ -432,8 +439,14 @@ extern int my_redel(const char *from, const char *to, int MyFlags);
extern int my_copystat(const char *from, const char *to, int MyFlags);
extern my_string my_filename(File fd);
+#ifndef THREAD
extern void dont_break(void);
extern void allow_break(void);
+#else
+#define dont_break()
+#define allow_break()
+#endif
+
extern void my_remember_signal(int signal_number,sig_handler (*func)(int));
extern void caseup(my_string str,uint length);
extern void casedn(my_string str,uint length);
diff --git a/include/myisam.h b/include/myisam.h
index ec141bb5912..d2cf3822575 100644
--- a/include/myisam.h
+++ b/include/myisam.h
@@ -68,6 +68,7 @@ typedef struct st_mi_isaminfo /* Struct from h_info */
ulong mean_reclength; /* Mean recordlength (if packed) */
ulonglong auto_increment;
ulonglong key_map; /* Which keys are used */
+ char *data_file_name, *index_file_name;
uint keys; /* Number of keys in use */
uint options; /* HA_OPTIONS_... used */
int errkey, /* With key was dupplicated on err */
@@ -86,6 +87,7 @@ typedef struct st_mi_isaminfo /* Struct from h_info */
typedef struct st_mi_create_info
{
+ char *index_file_name, *data_file_name; /* If using symlinks */
ha_rows max_rows;
ha_rows reloc_rows;
ulonglong auto_increment;
diff --git a/include/mysql.h b/include/mysql.h
index b5d918a98af..4ce7e80bcb9 100644
--- a/include/mysql.h
+++ b/include/mysql.h
@@ -127,6 +127,15 @@ typedef struct st_mysql_data {
struct st_mysql_options {
unsigned int connect_timeout,client_flag;
my_bool compress,named_pipe;
+ my_bool rpl_probe; /* on connect, find out the replication
+ role of the server, and establish connections
+ to all the peers */
+ my_bool rpl_parse; /* each call to mysql_real_query() will parse
+ it to tell if it is a read or a write, and
+ direct it to the slave or the master */
+ my_bool no_master_reads; /* if set, never read from
+ a master,only from slave, when doing
+ a read that is replication-aware */
unsigned int port;
char *host,*init_command,*user,*password,*unix_socket,*db;
char *my_cnf_file,*my_cnf_group, *charset_dir, *charset_name;
@@ -145,6 +154,14 @@ enum mysql_option { MYSQL_OPT_CONNECT_TIMEOUT, MYSQL_OPT_COMPRESS,
enum mysql_status { MYSQL_STATUS_READY,MYSQL_STATUS_GET_RESULT,
MYSQL_STATUS_USE_RESULT};
+/* there are three types of queries - the ones that have to go to
+ the master, the ones that go to a slave, and the adminstrative
+ type which must happen on the pivot connectioin
+*/
+enum mysql_rpl_type { MYSQL_RPL_MASTER, MYSQL_RPL_SLAVE,
+ MYSQL_RPL_ADMIN };
+
+
typedef struct st_mysql {
NET net; /* Communication parameters */
gptr connector_fd; /* ConnectorFd for SSL */
@@ -168,6 +185,21 @@ typedef struct st_mysql {
char scramble_buff[9];
struct charset_info_st *charset;
unsigned int server_language;
+
+ /* pointers to the master, and the next slave
+ connections, points to itself if lone connection */
+ struct st_mysql* master, *next_slave;
+
+ struct st_mysql* last_used_slave; /* needed for round-robin slave pick */
+ struct st_mysql* last_used_con; /* needed for send/read/store/use
+ result to work
+ correctly with replication
+ */
+ my_bool rpl_pivot; /* set if this is the original connection,
+ not a master or a slave we have added though
+ mysql_rpl_probe() or mysql_set_master()/
+ mysql_add_slave()
+ */
} MYSQL;
@@ -242,6 +274,46 @@ int STDCALL mysql_send_query(MYSQL *mysql, const char *q,
int STDCALL mysql_read_query_result(MYSQL *mysql);
int STDCALL mysql_real_query(MYSQL *mysql, const char *q,
unsigned int length);
+/* perform query on master */
+int STDCALL mysql_master_query(MYSQL *mysql, const char *q,
+ unsigned int length);
+int STDCALL mysql_master_send_query(MYSQL *mysql, const char *q,
+ unsigned int length);
+/* perform query on slave */
+int STDCALL mysql_slave_query(MYSQL *mysql, const char *q,
+ unsigned int length);
+int STDCALL mysql_slave_send_query(MYSQL *mysql, const char *q,
+ unsigned int length);
+
+/* enable/disable parsing of all queries to decide
+ if they go on master or slave */
+void STDCALL mysql_enable_rpl_parse(MYSQL* mysql);
+void STDCALL mysql_disable_rpl_parse(MYSQL* mysql);
+/* get the value of the parse flag */
+int STDCALL mysql_rpl_parse_enabled(MYSQL* mysql);
+
+/* enable/disable reads from master */
+void STDCALL mysql_enable_reads_from_master(MYSQL* mysql);
+void STDCALL mysql_disable_reads_from_master(MYSQL* mysql);
+/* get the value of the master read flag */
+int STDCALL mysql_reads_from_master_enabled(MYSQL* mysql);
+
+enum mysql_rpl_type STDCALL mysql_rpl_query_type(const char* q, int len);
+
+/* discover the master and its slaves */
+int STDCALL mysql_rpl_probe(MYSQL* mysql);
+
+/* set the master, close/free the old one, if it is not a pivot */
+int STDCALL mysql_set_master(MYSQL* mysql, const char* host,
+ unsigned int port,
+ const char* user,
+ const char* passwd);
+int STDCALL mysql_add_slave(MYSQL* mysql, const char* host,
+ unsigned int port,
+ const char* user,
+ const char* passwd);
+
+
int STDCALL mysql_create_db(MYSQL *mysql, const char *DB);
int STDCALL mysql_drop_db(MYSQL *mysql, const char *DB);
int STDCALL mysql_shutdown(MYSQL *mysql);
diff --git a/include/mysql_com.h b/include/mysql_com.h
index 874430910ef..67a483705ee 100644
--- a/include/mysql_com.h
+++ b/include/mysql_com.h
@@ -42,7 +42,8 @@ enum enum_server_command {COM_SLEEP,COM_QUIT,COM_INIT_DB,COM_QUERY,
COM_PROCESS_INFO,COM_CONNECT,COM_PROCESS_KILL,
COM_DEBUG,COM_PING,COM_TIME,COM_DELAYED_INSERT,
COM_CHANGE_USER, COM_BINLOG_DUMP,
- COM_TABLE_DUMP, COM_CONNECT_OUT};
+ COM_TABLE_DUMP, COM_CONNECT_OUT,
+ COM_REGISTER_SLAVE};
#define NOT_NULL_FLAG 1 /* Field can't be NULL */
#define PRI_KEY_FLAG 2 /* Field is part of a primary key */
@@ -100,15 +101,8 @@ enum enum_server_command {COM_SLEEP,COM_QUIT,COM_INIT_DB,COM_QUERY,
#define NET_WRITE_TIMEOUT 60 /* Timeout on write */
#define NET_WAIT_TIMEOUT 8*60*60 /* Wait for new query */
-#ifndef Vio_defined
-#define Vio_defined
-#ifdef HAVE_VIO
-class Vio; /* Fill Vio class in C++ */
-#else
struct st_vio; /* Only C */
typedef struct st_vio Vio;
-#endif
-#endif
typedef struct st_net {
Vio* vio;
@@ -226,9 +220,6 @@ my_bool check_scramble(const char *, const char *message,
unsigned long *salt,my_bool old_ver);
char *get_tty_password(char *opt_message);
void hash_password(unsigned long *result, const char *password);
-#ifdef __cplusplus
-}
-#endif
/* Some other useful functions */
@@ -236,6 +227,10 @@ void my_init(void);
void load_defaults(const char *conf_file, const char **groups,
int *argc, char ***argv);
+#ifdef __cplusplus
+}
+#endif
+
#define NULL_LENGTH ((unsigned long) ~0) /* For net_store_length */
#ifdef __WIN__
diff --git a/include/mysqld_error.h b/include/mysqld_error.h
index 4f46c40ff49..106c49dc110 100644
--- a/include/mysqld_error.h
+++ b/include/mysqld_error.h
@@ -205,4 +205,12 @@
#define ER_SLAVE_THREAD 1202
#define ER_TOO_MANY_USER_CONNECTIONS 1203
#define ER_SET_CONSTANTS_ONLY 1204
-#define ER_ERROR_MESSAGES 205
+#define ER_LOCK_WAIT_TIMEOUT 1205
+#define ER_LOCK_TABLE_FULL 1206
+#define ER_READ_ONLY_TRANSACTION 1207
+#define ER_DROP_DB_WITH_READ_LOCK 1208
+#define ER_CREATE_DB_WITH_READ_LOCK 1209
+#define ER_CONNECT_TO_MASTER 1210
+#define ER_QUERY_ON_MASTER 1211
+#define ER_SHOW_BINLOG_EVENTS 1212
+#define ER_ERROR_MESSAGES 213
diff --git a/include/mysys_err.h b/include/mysys_err.h
index b379f5bcbc9..2d23ead36b6 100644
--- a/include/mysys_err.h
+++ b/include/mysys_err.h
@@ -22,7 +22,7 @@ extern "C" {
#endif
#define GLOB 0 /* Error maps */
-#define GLOBERRS 24 /* Max number of error messages in map's */
+#define GLOBERRS 27 /* Max number of error messages in map's */
#define EE(X) globerrs[ X ] /* Defines to add error to right map */
extern const char * NEAR globerrs[]; /* my_error_messages is here */
@@ -51,6 +51,9 @@ extern const char * NEAR globerrs[]; /* my_error_messages is here */
#define EE_CANT_MKDIR 21
#define EE_UNKNOWN_CHARSET 22
#define EE_OUT_OF_FILERESOURCES 23
+#define EE_CANT_READLINK 24
+#define EE_CANT_SYMLINK 25
+#define EE_REALPATH 26
#ifdef __cplusplus
}
diff --git a/include/vio.h b/include/vio.h
deleted file mode 100644
index acea6280f45..00000000000
--- a/include/vio.h
+++ /dev/null
@@ -1,278 +0,0 @@
-/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-/* We implement virtual IO by trapping needed vio_* calls and mapping
- * them to different function pointers by type
- */
-
-
-
-
-/*
- * Purpose: include file for st_vio that will work with C and C++
- */
-
-#ifndef vio_violite_h_
-#define vio_violite_h_
-
-#include "my_net.h" /* needed because of struct in_addr */
-
-
-/* Simple vio interface in C; The functions are implemented in violite.c */
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-enum enum_vio_type { VIO_CLOSED, VIO_TYPE_TCPIP, VIO_TYPE_SOCKET,
- VIO_TYPE_NAMEDPIPE, VIO_TYPE_SSL};
-#ifndef st_vio_defined
-#define st_vio_defined
-struct st_vio; /* Only C */
-typedef struct st_vio st_vio;
-#endif
-
-st_vio* vio_new(my_socket sd,
- enum enum_vio_type type,
- my_bool localhost);
-#ifdef __WIN__
-st_vio* vio_new_win32pipe(HANDLE hPipe);
-#endif
-void vio_delete(st_vio* vio);
-
-#ifdef EMBEDDED_LIBRARY
-void vio_reset(st_vio *vio);
-#endif
-
-/*
- * vio_read and vio_write should have the same semantics
- * as read(2) and write(2).
- */
-int vio_read( st_vio* vio,
- gptr buf, int size);
-int vio_write( st_vio* vio,
- const gptr buf,
- int size);
-/*
- * Whenever the socket is set to blocking mode or not.
- */
-int vio_blocking( st_vio* vio,
- my_bool onoff);
-my_bool vio_is_blocking( st_vio* vio);
-/*
- * setsockopt TCP_NODELAY at IPPROTO_TCP level, when possible.
- */
- int vio_fastsend( st_vio* vio);
-/*
- * setsockopt SO_KEEPALIVE at SOL_SOCKET level, when possible.
- */
-int vio_keepalive( st_vio* vio,
- my_bool onoff);
-/*
- * Whenever we should retry the last read/write operation.
- */
-my_bool vio_should_retry( st_vio* vio);
-/*
- * When the workday is over...
- */
-int vio_close(st_vio* vio);
-/*
- * Short text description of the socket for those, who are curious..
- */
-const char* vio_description( st_vio* vio);
-
-/* Return the type of the connection */
- enum enum_vio_type vio_type(st_vio* vio);
-
-/* Return last error number */
-int vio_errno(st_vio *vio);
-
-/* Get socket number */
-my_socket vio_fd(st_vio *vio);
-
-/*
- * Remote peer's address and name in text form.
- */
-my_bool vio_peer_addr(st_vio * vio, char *buf);
-
-/* Remotes in_addr */
-
-void vio_in_addr(st_vio *vio, struct in_addr *in);
-
- /* Return 1 if there is data to be read */
-my_bool vio_poll_read(st_vio *vio,uint timeout);
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* vio_violite_h_ */
-#ifdef HAVE_VIO
-#ifndef DONT_MAP_VIO
-#define vio_delete(vio) (vio)->viodelete(vio)
-#define vio_errno(vio) (vio)->vioerrno(vio)
-#define vio_read(vio, buf, size) (vio)->read(vio,buf,size)
-#define vio_write(vio, buf, size) (vio)->write(vio, buf, size)
-#define vio_blocking(vio, set_blocking_mode) (vio)->vioblocking(vio, set_blocking_mode)
-#define vio_is_blocking(vio) (vio)->is_blocking(vio)
-#define vio_fastsend(vio) (vio)->fastsend(vio)
-#define vio_keepalive(vio, set_keep_alive) (vio)->viokeepalive(vio, set_keep_alive)
-#define vio_should_retry(vio) (vio)->should_retry(vio)
-#define vio_close(vio) ((vio)->vioclose)(vio)
-#define vio_peer_addr(vio, buf) (vio)->peer_addr(vio, buf)
-#define vio_in_addr(vio, in) (vio)->in_addr(vio, in)
-#define vio_poll_read(vio,timeout) (vio)->poll_read(vio,timeout)
-#endif /* !DONT_MAP_VIO */
-#endif /* HAVE_VIO */
-
-
-#ifdef HAVE_OPENSSL
-#include <openssl/x509.h>
-#include <openssl/ssl.h>
-#include <openssl/err.h>
-#include <openssl/pem.h>
-#include <openssl/asn1.h>
-#include "my_net.h" /* needed because of struct in_addr */
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-#ifndef st_vio_defined
-#define st_vio_defined
-struct st_vio; /* Only C */
-typedef struct st_vio st_vio;
-#endif
-
-void vio_ssl_delete(st_vio* vio);
-
-#ifdef EMBEDDED_LIBRARY
-void vio_reset(st_vio *vio);
-#endif
-
-int vio_ssl_read(st_vio* vio,gptr buf, int size);
-int vio_ssl_write(st_vio* vio,const gptr buf,int size);
-int vio_ssl_blocking(st_vio* vio,my_bool onoff);
-my_bool vio_ssl_is_blocking(st_vio* vio);
-
-/* setsockopt TCP_NODELAY at IPPROTO_TCP level, when possible. */
- int vio_ssl_fastsend(st_vio* vio);
-/* setsockopt SO_KEEPALIVE at SOL_SOCKET level, when possible. */
-int vio_ssl_keepalive(st_vio* vio, my_bool onoff);
-/* Whenever we should retry the last read/write operation. */
-my_bool vio_ssl_should_retry(st_vio* vio);
-/* When the workday is over... */
-int vio_ssl_close(st_vio* vio);
-/* Return last error number */
-int vio_ssl_errno(st_vio *vio);
-my_bool vio_ssl_peer_addr(st_vio * vio, char *buf);
-void vio_ssl_in_addr(st_vio *vio, struct in_addr *in);
-
-/* Return 1 if there is data to be read */
-my_bool vio_ssl_poll_read(st_vio *vio,uint timeout);
-
-#ifdef HAVE_OPENSSL
-
-/* Single copy for server */
-struct st_VioSSLAcceptorFd
-{
- SSL_CTX* ssl_context_;
- SSL_METHOD* ssl_method_;
- struct st_VioSSLAcceptorFd* session_id_context_;
- enum {
- state_connect = 1,
- state_accept = 2
- };
- BIO* bio_;
- char *ssl_cip_;
- char desc_[100];
- st_vio* sd_;
-
- /* function pointers which are only once for SSL server */
-// struct st_vio *(*sslaccept)(struct st_VioSSLAcceptorFd*,st_vio*);
-};
-
-/* One copy for client */
-struct st_VioSSLConnectorFd
-{
- BIO* bio_;
- gptr ssl_;
- SSL_CTX* ssl_context_;
- SSL_METHOD* ssl_method_;
- /* function pointers which are only once for SSL client */
-};
-struct st_vio *sslaccept(struct st_VioSSLAcceptorFd*, struct st_vio*);
-struct st_vio *sslconnect(struct st_VioSSLConnectorFd*, struct st_vio*);
-
-#else /* HAVE_OPENSSL */
-/* This dummy is required to maintain proper size of st_mysql in mysql.h */
-struct st_VioSSLConnectorFd {};
-#endif /* HAVE_OPENSSL */
-struct st_VioSSLConnectorFd *new_VioSSLConnectorFd(
- const char* key_file,const char* cert_file,const char* ca_file,const char* ca_path);
-struct st_VioSSLAcceptorFd *new_VioSSLAcceptorFd(
- const char* key_file,const char* cert_file,const char* ca_file,const char* ca_path);
-struct st_vio* new_VioSSL(struct st_VioSSLAcceptorFd* fd, struct st_vio * sd,int state);
-static int
-init_bio_(struct st_VioSSLAcceptorFd* fd, struct st_vio* sd, int state, int bio_flags);
-static void
-report_errors();
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* HAVE_OPENSSL */
-
-#ifndef __WIN__
-#define HANDLE void *
-#endif
-
-/* This structure is for every connection on both sides */
-struct st_vio
-{
- my_socket sd; /* my_socket - real or imaginary */
- HANDLE hPipe;
- my_bool localhost; /* Are we from localhost? */
- int fcntl_mode; /* Buffered fcntl(sd,F_GETFL) */
- struct sockaddr_in local; /* Local internet address */
- struct sockaddr_in remote; /* Remote internet address */
- enum enum_vio_type type; /* Type of connection */
- char desc[30]; /* String description */
-#ifdef HAVE_VIO
- /* function pointers. They are similar for socket/SSL/whatever */
- void (*viodelete)(st_vio *);
- int(*vioerrno)(st_vio*);
- int(*read)(st_vio*, gptr, int);
- int(*write)(st_vio*, gptr, int);
- int(*vioblocking)(st_vio*, my_bool);
- my_bool(*is_blocking)(st_vio*);
- int(*viokeepalive)(st_vio *, my_bool);
- int(*fastsend)(st_vio *);
- my_bool(*peer_addr)(st_vio*, gptr);
- void(*in_addr)(st_vio*, struct in_addr*);
- my_bool(*should_retry)(st_vio *);
- int(*vioclose)(st_vio *);
- my_bool(*poll_read)(st_vio *,uint);
-
-#ifdef HAVE_OPENSSL
- BIO* bio_;
- SSL* ssl_;
- my_bool open_;
-#endif /* HAVE_OPENSSL */
-#endif /* HAVE_VIO */
-};
-
-
diff --git a/include/violite.h b/include/violite.h
index 7b14dae3610..bc10a8f527c 100644
--- a/include/violite.h
+++ b/include/violite.h
@@ -25,9 +25,6 @@
#include "my_net.h" /* needed because of struct in_addr */
-#ifdef HAVE_VIO
-#include <Vio.h> /* Full VIO interface */
-#else
/* Simple vio interface in C; The functions are implemented in violite.c */
@@ -35,14 +32,12 @@
extern "C" {
#endif /* __cplusplus */
-#ifndef Vio_defined
-#define Vio_defined
-struct st_vio; /* Only C */
-typedef struct st_vio Vio;
-#endif
-
enum enum_vio_type { VIO_CLOSED, VIO_TYPE_TCPIP, VIO_TYPE_SOCKET,
- VIO_TYPE_NAMEDPIPE, VIO_TYPE_SSL};
+ VIO_TYPE_NAMEDPIPE, VIO_TYPE_SSL};
+
+#ifndef __WIN__
+#define HANDLE void *
+#endif
Vio* vio_new(my_socket sd,
enum enum_vio_type type,
@@ -54,6 +49,10 @@ void vio_delete(Vio* vio);
#ifdef EMBEDDED_LIBRARY
void vio_reset(Vio *vio);
+#else
+void vio_reset(Vio* vio, enum enum_vio_type type,
+ my_socket sd, HANDLE hPipe,
+ my_bool localhost);
#endif
/*
@@ -87,7 +86,7 @@ my_bool vio_should_retry( Vio* vio);
/*
* When the workday is over...
*/
-int vio_close( Vio* vio);
+int vio_close(Vio* vio);
/*
* Short text description of the socket for those, who are curious..
*/
@@ -97,15 +96,15 @@ const char* vio_description( Vio* vio);
enum enum_vio_type vio_type(Vio* vio);
/* Return last error number */
-int vio_errno(Vio *vio);
+int vio_errno(Vio*vio);
/* Get socket number */
-my_socket vio_fd(Vio *vio);
+my_socket vio_fd(Vio*vio);
/*
* Remote peer's address and name in text form.
*/
-my_bool vio_peer_addr(Vio * vio, char *buf);
+my_bool vio_peer_addr(Vio* vio, char *buf);
/* Remotes in_addr */
@@ -117,5 +116,142 @@ my_bool vio_poll_read(Vio *vio,uint timeout);
#ifdef __cplusplus
}
#endif
-#endif /* HAVE_VIO */
#endif /* vio_violite_h_ */
+#ifdef HAVE_VIO
+#ifndef DONT_MAP_VIO
+#define vio_delete(vio) (vio)->viodelete(vio)
+#define vio_errno(vio) (vio)->vioerrno(vio)
+#define vio_read(vio, buf, size) (vio)->read(vio,buf,size)
+#define vio_write(vio, buf, size) (vio)->write(vio, buf, size)
+#define vio_blocking(vio, set_blocking_mode) (vio)->vioblocking(vio, set_blocking_mode)
+#define vio_is_blocking(vio) (vio)->is_blocking(vio)
+#define vio_fastsend(vio) (vio)->fastsend(vio)
+#define vio_keepalive(vio, set_keep_alive) (vio)->viokeepalive(vio, set_keep_alive)
+#define vio_should_retry(vio) (vio)->should_retry(vio)
+#define vio_close(vio) ((vio)->vioclose)(vio)
+#define vio_peer_addr(vio, buf) (vio)->peer_addr(vio, buf)
+#define vio_in_addr(vio, in) (vio)->in_addr(vio, in)
+#define vio_poll_read(vio,timeout) (vio)->poll_read(vio,timeout)
+#endif /* !DONT_MAP_VIO */
+#endif /* HAVE_VIO */
+
+
+#ifdef HAVE_OPENSSL
+#include <openssl/x509.h>
+#include <openssl/ssl.h>
+#include <openssl/err.h>
+#include <openssl/pem.h>
+#include <openssl/asn1.h>
+#include "my_net.h" /* needed because of struct in_addr */
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+void vio_ssl_delete(Vio* vio);
+
+int vio_ssl_read(Vio* vio,gptr buf, int size);
+int vio_ssl_write(Vio* vio,const gptr buf,int size);
+int vio_ssl_blocking(Vio* vio,my_bool onoff);
+my_bool vio_ssl_is_blocking(Vio* vio);
+
+/* setsockopt TCP_NODELAY at IPPROTO_TCP level, when possible. */
+ int vio_ssl_fastsend(Vio* vio);
+/* setsockopt SO_KEEPALIVE at SOL_SOCKET level, when possible. */
+int vio_ssl_keepalive(Vio* vio, my_bool onoff);
+/* Whenever we should retry the last read/write operation. */
+my_bool vio_ssl_should_retry(Vio* vio);
+/* When the workday is over... */
+int vio_ssl_close(Vio* vio);
+/* Return last error number */
+int vio_ssl_errno(Vio *vio);
+my_bool vio_ssl_peer_addr(Vio* vio, char *buf);
+void vio_ssl_in_addr(Vio *vio, struct in_addr *in);
+
+/* Return 1 if there is data to be read */
+my_bool vio_ssl_poll_read(Vio *vio,uint timeout);
+
+#ifdef HAVE_OPENSSL
+
+/* Single copy for server */
+struct st_VioSSLAcceptorFd
+{
+ SSL_CTX* ssl_context_;
+ SSL_METHOD* ssl_method_;
+ struct st_VioSSLAcceptorFd* session_id_context_;
+ enum {
+ state_connect = 1,
+ state_accept = 2
+ };
+ BIO* bio_;
+ char *ssl_cip_;
+ char desc_[100];
+ Vio* sd_;
+
+ /* function pointers which are only once for SSL server
+ Vio*(*sslaccept)(struct st_VioSSLAcceptorFd*,Vio*); */
+};
+
+/* One copy for client */
+struct st_VioSSLConnectorFd
+{
+ SSL_CTX* ssl_context_;
+ SSL_METHOD* ssl_method_;
+ /* function pointers which are only once for SSL client */
+};
+Vio *sslaccept(struct st_VioSSLAcceptorFd*, Vio*);
+Vio *sslconnect(struct st_VioSSLConnectorFd*, Vio*);
+
+#else /* HAVE_OPENSSL */
+/* This dummy is required to maintain proper size of st_mysql in mysql.h */
+struct st_VioSSLConnectorFd {};
+#endif /* HAVE_OPENSSL */
+struct st_VioSSLConnectorFd *new_VioSSLConnectorFd(
+ const char* key_file,const char* cert_file,const char* ca_file,const char* ca_path);
+struct st_VioSSLAcceptorFd *new_VioSSLAcceptorFd(
+ const char* key_file,const char* cert_file,const char* ca_file,const char* ca_path);
+Vio* new_VioSSL(struct st_VioSSLAcceptorFd* fd, Vio* sd,int state);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* HAVE_OPENSSL */
+
+#ifndef EMBEDDED_LIBRARY
+/* This structure is for every connection on both sides */
+struct st_vio
+{
+ my_socket sd; /* my_socket - real or imaginary */
+ HANDLE hPipe;
+ my_bool localhost; /* Are we from localhost? */
+ int fcntl_mode; /* Buffered fcntl(sd,F_GETFL) */
+ struct sockaddr_in local; /* Local internet address */
+ struct sockaddr_in remote; /* Remote internet address */
+ enum enum_vio_type type; /* Type of connection */
+ char desc[30]; /* String description */
+#ifdef HAVE_VIO
+ /* function pointers. They are similar for socket/SSL/whatever */
+ void (*viodelete)(Vio*);
+ int(*vioerrno)(Vio*);
+ int(*read)(Vio*, gptr, int);
+ int(*write)(Vio*, gptr, int);
+ int(*vioblocking)(Vio*, my_bool);
+ my_bool(*is_blocking)(Vio*);
+ int(*viokeepalive)(Vio*, my_bool);
+ int(*fastsend)(Vio*);
+ my_bool(*peer_addr)(Vio*, gptr);
+ void(*in_addr)(Vio*, struct in_addr*);
+ my_bool(*should_retry)(Vio*);
+ int(*vioclose)(Vio*);
+ my_bool(*poll_read)(Vio*,uint);
+
+#ifdef HAVE_OPENSSL
+ BIO* bio_;
+ SSL* ssl_;
+ my_bool open_;
+#endif /* HAVE_OPENSSL */
+#endif /* HAVE_VIO */
+};
+#endif /* EMBEDDED_LIBRARY */
+