diff --git a/BUILD/compile-pentium-debug-openssl b/BUILD/compile-pentium-debug-openssl new file mode 100755 index 00000000000..aa120e3175a --- /dev/null +++ b/BUILD/compile-pentium-debug-openssl @@ -0,0 +1,13 @@ +#! /bin/sh + +path=`dirname $0` +. "$path/SETUP.sh" + +extra_flags="$pentium_cflags $debug_cflags" +c_warnings="$c_warnings $debug_extra_warnings" +cxx_warnings="$cxx_warnings $debug_extra_warnings" +extra_configs="$pentium_configs $debug_configs" + +extra_configs="$extra_configs --with-debug=full --with-vio --with-openssl" + +. "$path/FINISH.sh" diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index c2b1bc573f4..709fb003c88 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -1,3 +1,4 @@ +heikki@donna.mysql.fi jani@janikt.pp.saunalahti.fi monty@hundin.mysql.fi monty@work.mysql.com diff --git a/Docs/manual.texi b/Docs/manual.texi index 02d698810b3..83e607b19cc 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -44926,7 +44926,9 @@ table for a different site you are working on, but the table is just a bit different (that is - fields in different order, etc.). By Steve Shreeve. @item @uref{http://www.mysql.com/Downloads/Contrib/oracledump, oracledump} -Perl program to convert Oracle databases to @strong{MySQL}. By Johan Andersson. +Perl program to convert Oracle databases to @strong{MySQL}. Has same +output format as mysqldump. By Johan Andersson. + @item @uref{http://www.mysql.com/Downloads/Contrib/excel2mysql, excel2mysql} Perl program to import Excel spreadsheets into a @strong{MySQL} database. By Stephen Hurd @email{shurd@@sk.sympatico.ca} diff --git a/Makefile.am b/Makefile.am index 7343f617449..d6bfb156d29 100644 --- a/Makefile.am +++ b/Makefile.am @@ -22,7 +22,7 @@ TAR = gtar EXTRA_DIST = INSTALL-SOURCE README \ COPYING COPYING.LIB MIRRORS SUBDIRS = include @docs_dirs@ @readline_dir@ \ - @thread_dirs@ @pstack_dirs@ @sql_client_dirs@ \ + @thread_dirs@ @pstack_dirs@ vio @sql_client_dirs@ \ @sql_server_dirs@ @libmysqld_dirs@ scripts tests man \ @bench_dirs@ support-files @fs_dirs@ diff --git a/bdb/include/rpc_server_ext.h b/bdb/include/rpc_server_ext.h deleted file mode 100644 index 4abb0768134..00000000000 --- a/bdb/include/rpc_server_ext.h +++ /dev/null @@ -1,21 +0,0 @@ -/* DO NOT EDIT: automatically built by dist/s_include. */ -#ifndef _rpc_server_ext_h_ -#define _rpc_server_ext_h_ -#if defined(__cplusplus) -extern "C" { -#endif -void __db_stats_freelist __P((__db_stat_statsreplist **)); -void __dbsrv_settimeout __P((ct_entry *, u_int32_t)); -void __dbsrv_timeout __P((int)); -void __dbclear_ctp __P((ct_entry *)); -void __dbdel_ctp __P((ct_entry *)); -ct_entry *new_ct_ent __P((u_int32_t *)); -ct_entry *get_tableent __P((long)); -void __dbsrv_active __P((ct_entry *)); -int __dbc_close_int __P((ct_entry *)); -int __dbenv_close_int __P((long, int)); -char *get_home __P((char *)); -#if defined(__cplusplus) -} -#endif -#endif /* _rpc_server_ext_h_ */ diff --git a/client/Makefile.am b/client/Makefile.am index 24221dcab74..408fa360e67 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -20,7 +20,7 @@ INCLUDES = -I$(srcdir)/../include \ -I../include -I$(srcdir)/.. -I$(top_srcdir) \ -I.. LIBS = @CLIENT_LIBS@ -LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysql/libmysqlclient.la +LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysql/libmysqlclient.la ../vio/libvio.a bin_PROGRAMS = mysql mysqladmin mysqlcheck mysqlshow mysqldump mysqlimport mysqltest noinst_PROGRAMS = insert_test select_test thread_test noinst_HEADERS = sql_string.h completion_hash.h my_readline.h diff --git a/include/my_sys.h b/include/my_sys.h index 489015d42e2..b1008858bae 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -386,6 +386,8 @@ 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, diff --git a/include/mysql_com.h b/include/mysql_com.h index 4245101a440..67a483705ee 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -101,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; @@ -227,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 */ @@ -237,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/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 -#include -#include -#include -#include -#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..a88b5c0db51 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 /* Full VIO interface */ -#else /* Simple vio interface in C; The functions are implemented in violite.c */ @@ -35,14 +32,8 @@ 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}; Vio* vio_new(my_socket sd, enum enum_vio_type type, @@ -87,7 +78,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 +88,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 +108,154 @@ 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 +#include +#include +#include +#include +#include "my_net.h" /* needed because of struct in_addr */ + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +void vio_ssl_delete(Vio* vio); + +#ifdef EMBEDDED_LIBRARY +void vio_reset(Vio *vio); +#endif + +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 +{ + BIO* bio_; + gptr ssl_; + 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); +//static int +//init_bio_(struct st_VioSSLAcceptorFd* fd, Vio* sd, int state, int bio_flags); +//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)(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 */ +}; + + diff --git a/innobase/include/sync0sync.ic b/innobase/include/sync0sync.ic index 5a872c6b093..b58d024bf6c 100644 --- a/innobase/include/sync0sync.ic +++ b/innobase/include/sync0sync.ic @@ -94,10 +94,12 @@ mutex_test_and_set( /* In assembly we use the so-called AT & T syntax where the order of operands is inverted compared to the ordinary Intel - syntax. The 'l' after the mnemonics denotes a 32-bit operation. */ + syntax. The 'l' after the mnemonics denotes a 32-bit operation. + The line after the code tells which values come out of the asm + code, and the second line tells the input to the asm code. */ asm volatile("movl $1, %%eax; xchgl (%%ecx), %%eax" : - "=eax" (res): + "=eax" (res), "=m" (*lw) : "ecx" (lw)); return(res); #else @@ -132,12 +134,26 @@ mutex_reset_lock_word( __asm MOV EDX, 0 __asm MOV ECX, lw __asm XCHG EDX, DWORD PTR [ECX] +#elif defined(__GNUC__) && defined(UNIV_INTEL_X86) + ulint* lw; + + lw = &(mutex->lock_word); + + /* In assembly we use the so-called AT & T syntax where + the order of operands is inverted compared to the ordinary Intel + syntax. The 'l' after the mnemonics denotes a 32-bit operation. */ + + asm volatile("movl $0, %%eax; xchgl (%%ecx), %%eax" : + "=m" (*lw) : + "ecx" (lw) : + "eax"); /* gcc does not seem to understand + that our asm code resets eax: tell it + explicitly that after the third ':' */ #else mutex->lock_word = 0; -#if !(defined(__GNUC__) && defined(UNIV_INTEL_X86)) + os_fast_mutex_unlock(&(mutex->os_fast_mutex)); #endif -#endif } /********************************************************************** diff --git a/libmysql/Makefile.shared b/libmysql/Makefile.shared index 3bb73b87aab..0710484cbbe 100644 --- a/libmysql/Makefile.shared +++ b/libmysql/Makefile.shared @@ -34,9 +34,6 @@ LTCHARSET_OBJS= ${CHARSET_OBJS:.o=.lo} target_sources = libmysql.c net.c password.c \ get_password.c errmsg.c -#quick easy dirty hack to make it work after Tonu's changes -#In my opinion, violite.c really belongs into mysys - Sasha -sqlobjects = violite.lo mystringsobjects = strmov.lo strxmov.lo strnmov.lo strmake.lo strend.lo \ strnlen.lo strfill.lo is_prefix.lo \ int2str.lo str2int.lo strinstr.lo strcont.lo \ diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 9221812ea65..d9e7b28d468 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -1070,13 +1070,15 @@ mysql_ssl_set(MYSQL *mysql, const char *key, const char *cert, mysql->options.ssl_cert = cert==0 ? 0 : my_strdup(cert,MYF(0)); mysql->options.ssl_ca = ca==0 ? 0 : my_strdup(ca,MYF(0)); mysql->options.ssl_capath = capath==0 ? 0 : my_strdup(capath,MYF(0)); - mysql->options.use_ssl = true; - mysql->connector_fd = new_VioSSLConnectorFd(key, cert, ca, capath); + mysql->options.use_ssl = TRUE; + mysql->connector_fd = (gptr)new_VioSSLConnectorFd(key, cert, ca, capath); + DBUG_PRINT("info",("mysql_ssl_set, context: %p",((struct st_VioSSLConnectorFd *)(mysql->connector_fd))->ssl_context_)); + return 0; } /************************************************************************** -**************************************************************************/ +************************************************************************** char * STDCALL mysql_ssl_cipher(MYSQL *mysql) @@ -1085,10 +1087,10 @@ mysql_ssl_cipher(MYSQL *mysql) } -/************************************************************************** +************************************************************************** ** Free strings in the SSL structure and clear 'use_ssl' flag. ** NB! Errors are not reported until you do mysql_real_connect. -**************************************************************************/ +************************************************************************** int STDCALL mysql_ssl_clear(MYSQL *mysql) @@ -1105,7 +1107,7 @@ mysql_ssl_clear(MYSQL *mysql) mysql->connector_fd->delete(); mysql->connector_fd = 0; return 0; -} +}*/ #endif /* HAVE_OPENSSL */ /************************************************************************** @@ -1496,11 +1498,9 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, goto error; /* Do the SSL layering. */ DBUG_PRINT("info", ("IO layer change in progress...")); - VioSSLConnectorFd* connector_fd = (VioSSLConnectorFd*) - (mysql->connector_fd); - VioSocket* vio_socket = (VioSocket*)(mysql->net.vio); - VioSSL* vio_ssl = connector_fd->connect(vio_socket); - mysql->net.vio = (NetVio*)(vio_ssl); + DBUG_PRINT("info", ("IO context %p",((struct st_VioSSLConnectorFd*)mysql->connector_fd)->ssl_context_)); + mysql->net.vio = sslconnect((struct st_VioSSLConnectorFd*)(mysql->connector_fd),mysql->net.vio); + DBUG_PRINT("info", ("IO layer change done!")); } #endif /* HAVE_OPENSSL */ @@ -1680,8 +1680,8 @@ mysql_close(MYSQL *mysql) bzero((char*) &mysql->options,sizeof(mysql->options)); mysql->net.vio = 0; #ifdef HAVE_OPENSSL - ((VioConnectorFd*)(mysql->connector_fd))->delete(); - mysql->connector_fd = 0; +/* ((VioConnectorFd*)(mysql->connector_fd))->delete(); + mysql->connector_fd = 0;*/ #endif /* HAVE_OPENSSL */ if (mysql->free_me) my_free((gptr) mysql,MYF(0)); diff --git a/libmysql/net.c b/libmysql/net.c index 809cfb41e83..0fc5cf8b50c 100644 --- a/libmysql/net.c +++ b/libmysql/net.c @@ -31,6 +31,7 @@ #include #endif #include +#include #include #include #include diff --git a/mysys/Makefile.am b/mysys/Makefile.am index 827367ac755..6dd9bb06fe9 100644 --- a/mysys/Makefile.am +++ b/mysys/Makefile.am @@ -33,7 +33,7 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c\ my_alloc.c safemalloc.c my_fopen.c my_fstream.c \ my_error.c errors.c my_div.c my_messnc.c \ mf_format.c mf_same.c mf_dirname.c mf_fn_ext.c \ - my_symlink.c \ + my_symlink.c my_symlink2.c \ mf_pack.c mf_pack2.c mf_unixpath.c mf_stripp.c \ mf_casecnv.c mf_soundex.c mf_wcomp.c mf_wfile.c \ mf_qsort.c mf_qsort2.c mf_sort.c \ diff --git a/mysys/mf_same.c b/mysys/mf_same.c index 5b8c5ecf970..c1a5cae11cb 100644 --- a/mysys/mf_same.c +++ b/mysys/mf_same.c @@ -20,19 +20,22 @@ #include "mysys_priv.h" #include - /* Formaterar ett filnamn i avsende p} ett annat namn */ - /* Klarar {ven to = name */ - /* Denna funktion r|r inte p} utg}ngsnamnet */ + /* + Copy directory and/or extension between filenames. + (For the meaning of 'flag', check mf_format.c) + 'to' may be equal to 'name'. + Returns 'to'. + */ -my_string fn_same(my_string toname, const char *name, int flag) +my_string fn_same(char *to, const char *name, int flag) { char dev[FN_REFLEN]; const char *ext; DBUG_ENTER("fn_same"); - DBUG_PRINT("mfunkt",("to: %s name: %s flag: %d",toname,name,flag)); + DBUG_PRINT("enter",("to: %s name: %s flag: %d",to,name,flag)); if ((ext=strrchr(name+dirname_part(dev,name),FN_EXTCHAR)) == 0) ext=""; - DBUG_RETURN(fn_format(toname,toname,dev,ext,flag)); + DBUG_RETURN(fn_format(to,to,dev,ext,flag)); } /* fn_same */ diff --git a/mysys/my_symlink.c b/mysys/my_symlink.c index e195adcd4c5..65d165fc026 100644 --- a/mysys/my_symlink.c +++ b/mysys/my_symlink.c @@ -18,6 +18,7 @@ #include "mysys_priv.h" #include "mysys_err.h" #include +#include #ifdef HAVE_REALPATH #include #include @@ -26,13 +27,16 @@ /* Reads the content of a symbolic link If the file is not a symbolic link, return the original file name in to. + Returns: 0 if table was a symlink, + 1 if table was a normal file + -1 on error. */ int my_readlink(char *to, const char *filename, myf MyFlags) { #ifndef HAVE_READLINK strmov(to,filename); - return 0; + return 1; #else int result=0; int length; @@ -43,6 +47,7 @@ int my_readlink(char *to, const char *filename, myf MyFlags) /* Don't give an error if this wasn't a symlink */ if ((my_errno=errno) == EINVAL) { + result= 1; strmov(to,filename); } else @@ -81,44 +86,6 @@ int my_symlink(const char *content, const char *linkname, myf MyFlags) #endif /* HAVE_READLINK */ } - -/* - Create a file and a symbolic link that points to this file - If linkname is a null pointer or equal to filename, we don't - create a link. - */ - - -File my_create_with_symlink(const char *linkname, const char *filename, - int createflags, int access_flags, myf MyFlags) -{ - File file; - int tmp_errno; - DBUG_ENTER("my_create_with_symlink"); - if ((file=my_create(filename, createflags, access_flags, MyFlags)) >= 0) - { - /* Test if we should create a link */ - if (linkname && strcmp(linkname,filename)) - { - /* Delete old link/file */ - if (MyFlags & MY_DELETE_OLD) - my_delete(linkname, MYF(0)); - /* Create link */ - if (my_symlink(filename, linkname, MyFlags)) - { - /* Fail, remove everything we have done */ - tmp_errno=my_errno; - my_close(file,MYF(0)); - my_delete(filename, MYF(0)); - file= -1; - my_errno=tmp_errno; - } - } - } - DBUG_RETURN(file); -} - - /* Resolve all symbolic links in path 'to' may be equal to 'filename' @@ -162,7 +129,7 @@ int my_realpath(char *to, const char *filename, myf MyFlags) result= -1; } } - return result; + DBUG_RETURN(result); #else if (to != filename) strmov(to,filename); diff --git a/mysys/my_symlink2.c b/mysys/my_symlink2.c new file mode 100644 index 00000000000..671531393f7 --- /dev/null +++ b/mysys/my_symlink2.c @@ -0,0 +1,131 @@ +/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, + MA 02111-1307, USA */ + +/* + Advanced symlink handling. + This is used in MyISAM to let users symlinks tables to different disk. + The main idea with these functions is to automaticly create, delete and + rename files and symlinks like they would be one unit. +*/ + +#include "mysys_priv.h" +#include + +File my_create_with_symlink(const char *linkname, const char *filename, + int createflags, int access_flags, myf MyFlags) +{ + File file; + int tmp_errno; + DBUG_ENTER("my_create_with_symlink"); + if ((file=my_create(filename, createflags, access_flags, MyFlags)) >= 0) + { + /* Test if we should create a link */ + if (linkname && strcmp(linkname,filename)) + { + /* Delete old link/file */ + if (MyFlags & MY_DELETE_OLD) + my_delete(linkname, MYF(0)); + /* Create link */ + if (my_symlink(filename, linkname, MyFlags)) + { + /* Fail, remove everything we have done */ + tmp_errno=my_errno; + my_close(file,MYF(0)); + my_delete(filename, MYF(0)); + file= -1; + my_errno=tmp_errno; + } + } + } + DBUG_RETURN(file); +} + +/* + If the file was a symlink, delete both symlink and the file which the + symlink pointed to. +*/ + +int my_delete_with_symlink(const char *name, myf MyFlags) +{ + char link_name[FN_REFLEN]; + int was_symlink= !my_readlink(link_name, name, MYF(0)); + int result; + DBUG_ENTER("my_delete_with_symlink"); + + if (!(result=my_delete(name, MyFlags))) + { + if (was_symlink) + result=my_delete(link_name, MyFlags); + } + DBUG_RETURN(result); +} + +/* + If the file is a normal file, just rename it. + If the file is a symlink: + - Create a new file with the name 'to' that points at + symlink_dir/basename(to) + - Rename the symlinked file to symlink_dir/basename(to) + - Delete 'from' + If something goes wrong, restore everything. +*/ + +int my_rename_with_symlink(const char *from, const char *to, myf MyFlags) +{ +#ifdef HAVE_READLINK + return my_rename(from, to, MyFlags); +#else + char link_name[FN_REFLEN], tmp_name[FN_REFLEN]; + int was_symlink= !my_readlink(link_name, name, MYF(0)); + int result; + DBUG_ENTER("my_rename_with_symlink"); + + if (!was_symlink) + DBUG_RETURN(my_rename(from, to, MyFlags)); + + /* Change filename that symlink pointed to */ + strmov(tmp_name, to); + fn_same(tmp_name,link_name,1); /* Copy dir */ + + /* Create new symlink */ + if (my_symlink(tmp_name, to, MyFlags)) + DBUG_RETURN(-1); + + /* + Rename symlinked file if the base name didn't change. + This can happen if you use this function where 'from' and 'to' has + the same basename and different directories. + */ + + if (strcmp(link_name, tmp_name) && my_rename(link_name, tmp_name, MyFlags)) + { + my_delete(to, MyFlags); /* Remove created symlink */ + DBUG_RETURN(-1); + } + + /* Remove original symlink */ + if (my_delete(from, MyFlags)) + { + /* Remove created link */ + my_delete(to, MyFlags); + /* Rename file back */ + if (strcmp(link_name, tmp_name)) + (void) my_rename(tmp_name, link_name, MyFlags); + } + DBUG_RETURN(result); +#endif /* HAVE_READLINK */ +} diff --git a/sql/Makefile.am b/sql/Makefile.am index c4ed5c05cd3..f4ff799b49b 100644 --- a/sql/Makefile.am +++ b/sql/Makefile.am @@ -39,8 +39,8 @@ LDADD = ../isam/libnisam.a \ ../mysys/libmysys.a \ ../dbug/libdbug.a \ ../regex/libregex.a \ - ../strings/libmystrings.a - #../vio/libvio.a + ../strings/libmystrings.a \ + ../vio/libvio.a mysqld_LDADD = @MYSQLD_EXTRA_LDFLAGS@ \ @bdb_libs@ @innodb_libs@ @pstack_libs@ \ @@ -64,7 +64,7 @@ mysqld_SOURCES = sql_lex.cc sql_handler.cc \ item_cmpfunc.cc item_strfunc.cc item_timefunc.cc \ thr_malloc.cc item_create.cc \ field.cc key.cc sql_class.cc sql_list.cc \ - net_serv.cc violite.c net_pkg.cc lock.cc my_lock.c \ + net_serv.cc net_pkg.cc lock.cc my_lock.c \ sql_string.cc sql_manager.cc sql_map.cc \ mysqld.cc password.c hash_filo.cc hostname.cc \ convert.cc sql_parse.cc sql_yacc.yy \ @@ -86,7 +86,7 @@ mysqld_SOURCES = sql_lex.cc sql_handler.cc \ md5.c stacktrace.c gen_lex_hash_SOURCES = gen_lex_hash.cc gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS) -mysqlbinlog_SOURCES = mysqlbinlog.cc mini_client.cc net_serv.cc violite.c \ +mysqlbinlog_SOURCES = mysqlbinlog.cc mini_client.cc net_serv.cc \ mini_client_errors.c password.c mysqlbinlog_LDADD = $(LDADD) $(CXXLDFLAGS) $(mysqld_LDADD) diff --git a/sql/mini_client.cc b/sql/mini_client.cc index b99e63a59d7..8966b303000 100644 --- a/sql/mini_client.cc +++ b/sql/mini_client.cc @@ -28,6 +28,8 @@ #include #endif #include +#include +#include #include #include #include @@ -37,7 +39,6 @@ #include "mysql_version.h" #include "mysqld_error.h" #include "errmsg.h" -#include extern "C" { // Because of SCO 3.2V4.2 #include @@ -748,18 +749,18 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user, #ifdef HAVE_OPENSSL /* Oops.. are we careful enough to not send ANY information */ /* without encryption? */ - if (client_flag & CLIENT_SSL) +/* if (client_flag & CLIENT_SSL) { if (my_net_write(net,buff,(uint) (2)) || net_flush(net)) - goto error; + goto error;*/ /* Do the SSL layering. */ - DBUG_PRINT("info", ("IO layer change in progress...")); + /* DBUG_PRINT("info", ("IO layer change in progress...")); VioSSLConnectorFd* connector_fd = (VioSSLConnectorFd*) (mysql->connector_fd); VioSocket* vio_socket = (VioSocket*)(mysql->net.vio); VioSSL* vio_ssl = connector_fd->connect(vio_socket); mysql->net.vio = (NetVio*)(vio_ssl); - } + }*/ #endif /* HAVE_OPENSSL */ int3store(buff+2,max_allowed_packet); @@ -829,8 +830,8 @@ mc_mysql_close(MYSQL *mysql) bzero((char*) &mysql->options,sizeof(mysql->options)); mysql->net.vio = 0; #ifdef HAVE_OPENSSL - ((VioConnectorFd*)(mysql->connector_fd))->delete(); - mysql->connector_fd = 0; +/* ((VioConnectorFd*)(mysql->connector_fd))->delete(); + mysql->connector_fd = 0;*/ #endif /* HAVE_OPENSSL */ if (mysql->free_me) my_free((gptr) mysql,MYF(0)); diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index aaf1d4200df..ef8f4efbb6c 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -26,7 +26,6 @@ #include #include /* Needed by field.h */ #include -#include #undef write // remove pthread.h macro definition for EMX @@ -35,6 +34,7 @@ typedef ulong key_map; /* Used for finding keys */ typedef ulong key_part_map; /* Used for finding key parts */ #include "mysql_com.h" +#include #include "unireg.h" void init_sql_alloc(MEM_ROOT *root, uint block_size, uint pre_alloc_size); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 590e59f9a7d..65f70e7702d 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -35,7 +35,6 @@ #include #include #include -#include "vio.h" #ifndef DBUG_OFF #define ONE_THREAD @@ -245,7 +244,7 @@ static char *opt_ssl_key = 0; static char *opt_ssl_cert = 0; static char *opt_ssl_ca = 0; static char *opt_ssl_capath = 0; -static struct st_VioSSLAcceptorFd * ssl_acceptor_fd = 0; +struct st_VioSSLAcceptorFd * ssl_acceptor_fd = 0; #endif /* HAVE_OPENSSL */ diff --git a/sql/net_serv.cc b/sql/net_serv.cc index a5600dffa4c..cde27d4933a 100644 --- a/sql/net_serv.cc +++ b/sql/net_serv.cc @@ -31,6 +31,7 @@ #include #endif #include +#include #include #include #include @@ -39,7 +40,6 @@ #include #include #include -#include #include extern "C" { diff --git a/sql/slave.cc b/sql/slave.cc index 5b5439353c7..7bf89fdad48 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -963,36 +963,37 @@ static int exec_event(THD* thd, NET* net, MASTER_INFO* mi, int event_len) // sanity check to make sure the master did not get a really bad // error on the query - if(!check_expected_error(thd, (expected_error = qev->error_code))) + if (!check_expected_error(thd, (expected_error = qev->error_code))) + { + mysql_parse(thd, thd->query, q_len); + if (expected_error != + (actual_error = thd->net.last_errno) && expected_error) { - mysql_parse(thd, thd->query, q_len); - if (expected_error != - (actual_error = thd->net.last_errno) && expected_error) - { - const char* errmsg = "Slave: did not get the expected error\ - running query from master - expected: '%s', got '%s'"; - sql_print_error(errmsg, ER(expected_error), - actual_error ? thd->net.last_error:"no error" - ); - thd->query_error = 1; - } - else if (expected_error == actual_error) - { - thd->query_error = 0; - *last_slave_error = 0; - last_slave_errno = 0; - } + const char* errmsg = "Slave: did not get the expected error\ + running query from master - expected: '%s'(%d), got '%s'(%d)"; + sql_print_error(errmsg, ER_SAFE(expected_error), + expected_error, + actual_error ? thd->net.last_error:"no error", + actual_error); + thd->query_error = 1; } - else // master could be inconsistent, abort and tell DBA to - // check/fix it + else if (expected_error == actual_error) { - thd->db = thd->query = 0; - thd->convert_set = 0; - close_thread_tables(thd); - free_root(&thd->mem_root,0); - delete ev; - return 1; + thd->query_error = 0; + *last_slave_error = 0; + last_slave_errno = 0; } + } + else + { + // master could be inconsistent, abort and tell DBA to check/fix it + thd->db = thd->query = 0; + thd->convert_set = 0; + close_thread_tables(thd); + free_root(&thd->mem_root,0); + delete ev; + return 1; + } } thd->db = 0; // prevent db from being freed thd->query = 0; // just to be sure diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index cccb58b1ea0..c8a750c8da6 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -60,7 +60,7 @@ const char *command_name[]={ bool volatile abort_slave = 0; #ifdef HAVE_OPENSSL -extern VioSSLAcceptorFd* ssl_acceptor_fd; +extern struct st_VioSSLAcceptorFd * ssl_acceptor_fd; #endif /* HAVE_OPENSSL */ #ifdef __WIN__ @@ -424,9 +424,7 @@ check_connections(THD *thd) DBUG_PRINT("info", ("Agreed to change IO layer to SSL") ); /* Do the SSL layering. */ DBUG_PRINT("info", ("IO layer change in progress...")); - VioSocket* vio_socket = my_reinterpret_cast(VioSocket*)(net->vio); - VioSSL* vio_ssl = ssl_acceptor_fd->accept(vio_socket); - net->vio = my_reinterpret_cast(NetVio*) (vio_ssl); + net->vio = sslaccept(ssl_acceptor_fd, net->vio); DBUG_PRINT("info", ("Reading user information over SSL layer")); if ((pkt_len=my_net_read(net)) == packet_error || pkt_len < NORMAL_HANDSHAKE_SIZE) diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 74a3549149b..fe0417057b6 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -764,14 +764,18 @@ int change_master(THD* thd) // if we change host or port, we must reset the postion glob_mi.log_file_name[0] = 0; glob_mi.pos = 4; // skip magic number + glob_mi.pending = 0; } if(lex_mi->log_file_name) strmake(glob_mi.log_file_name, lex_mi->log_file_name, sizeof(glob_mi.log_file_name)); if(lex_mi->pos) + { glob_mi.pos = lex_mi->pos; - + glob_mi.pending = 0; + } + if(lex_mi->host) { strmake(glob_mi.host, lex_mi->host, sizeof(glob_mi.host)); diff --git a/sql/unireg.h b/sql/unireg.h index 7ad3bac2eab..159832295fd 100644 --- a/sql/unireg.h +++ b/sql/unireg.h @@ -38,6 +38,8 @@ #endif #define ER(X) errmesg[(X)-1000] +#define ER_SAFE(X) (((X) >= 1000 && (X) < ER_ERROR_MESSAGES + 1000) ? ER(X) : "Invalid error code") + #define ERRMAPP 1 /* Errormap f|r my_error */ #define LIBLEN FN_REFLEN-FN_LEN /* Max l{ngd p} dev */ diff --git a/vio/Makefile.am b/vio/Makefile.am index 9bb8691eee6..c1a69b26058 100644 --- a/vio/Makefile.am +++ b/vio/Makefile.am @@ -14,20 +14,12 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -INCLUDES = -I$(srcdir)/../include -I../include \ - @OPENSSL_INCLUDES@ -LDADD = libvio.la -pkglib_LTLIBRARIES = libvio.la +INCLUDES = -I$(srcdir)/../include -I../include $(openssl_includes) +LDADD = libvio.a $(openssl_libs) +pkglib_LIBRARIES = libvio.a noinst_PROGRAMS = noinst_HEADERS = -libvio_la_SOURCES = \ - Vio.cc VioAcceptorFd.cc \ - VioConnectorFd.cc VioFd.cc \ - VioHandle.cc VioSSL.cc \ - VioSSLFactoriesFd.cc VioSocket.cc \ - auto.cc hostnamexx.cc \ - vdbug.cc version.cc \ - vmem.cc violitexx.cc +libvio_a_SOURCES = vio.c viosocket.c viossl.c viosslfactories.c OMIT_DEPENDENCIES = pthread.h stdio.h __stdio.h stdlib.h __stdlib.h math.h\ __math.h time.h __time.h unistd.h __unistd.h types.h \ diff --git a/vio/vio.c b/vio/vio.c index 9775c002737..689a01f4475 100644 --- a/vio/vio.c +++ b/vio/vio.c @@ -23,10 +23,11 @@ #define DONT_MAP_VIO #include +#include +#include #include #include -#include #include #include #include @@ -58,14 +59,14 @@ /* - * Helper to fill most of the st_vio* with defaults. + * Helper to fill most of the Vio* with defaults. */ -void vio_reset(st_vio* vio, enum enum_vio_type type, +void vio_reset(Vio* vio, enum enum_vio_type type, my_socket sd, HANDLE hPipe, my_bool localhost) { - bzero((char*) vio, sizeof(st_vio)); + bzero((char*) vio, sizeof(Vio)); vio->type = type; vio->sd = sd; vio->hPipe = hPipe; @@ -102,12 +103,12 @@ if(type == VIO_TYPE_SSL){ /* Open the socket or TCP/IP connection and read the fnctl() status */ -st_vio *vio_new(my_socket sd, enum enum_vio_type type, my_bool localhost) +Vio *vio_new(my_socket sd, enum enum_vio_type type, my_bool localhost) { - st_vio *vio; + Vio *vio; DBUG_ENTER("vio_new"); DBUG_PRINT("enter", ("sd=%d", sd)); - if ((vio = (st_vio*) my_malloc(sizeof(*vio),MYF(MY_WME)))) + if ((vio = (Vio*) my_malloc(sizeof(*vio),MYF(MY_WME)))) { vio_reset(vio, type, sd, 0, localhost); sprintf(vio->desc, @@ -134,11 +135,11 @@ st_vio *vio_new(my_socket sd, enum enum_vio_type type, my_bool localhost) #ifdef __WIN__ -st_vio *vio_new_win32pipe(HANDLE hPipe) +Vio *vio_new_win32pipe(HANDLE hPipe) { - st_vio *vio; + Vio *vio; DBUG_ENTER("vio_new_handle"); - if ((vio = (st_vio*) my_malloc(sizeof(st_vio),MYF(MY_WME)))) + if ((vio = (Vio*) my_malloc(sizeof(Vio),MYF(MY_WME)))) { vio_reset(vio, VIO_TYPE_NAMEDPIPE, 0, hPipe, TRUE); strmov(vio->desc, "named pipe"); diff --git a/vio/viotcpip.c b/vio/viosocket.c similarity index 90% rename from vio/viotcpip.c rename to vio/viosocket.c index f0dfc81cf4f..16260f92596 100644 --- a/vio/viotcpip.c +++ b/vio/viosocket.c @@ -24,10 +24,11 @@ #define DONT_MAP_VIO #include +#include #include #include -#include +#include #include #include #include @@ -61,7 +62,7 @@ #define HANDLE void * #endif -void vio_delete(st_vio* vio) +void vio_delete(Vio* vio) { /* It must be safe to delete null pointers. */ /* This matches the semantics of C++'s delete operator. */ @@ -73,13 +74,13 @@ void vio_delete(st_vio* vio) } } -int vio_errno(st_vio *vio __attribute__((unused))) +int vio_errno(Vio *vio __attribute__((unused))) { return errno; /* On Win32 this mapped to WSAGetLastError() */ } -int vio_read(st_vio * vio, gptr buf, int size) +int vio_read(Vio * vio, gptr buf, int size) { int r; DBUG_ENTER("vio_read"); @@ -108,7 +109,7 @@ int vio_read(st_vio * vio, gptr buf, int size) } -int vio_write(st_vio * vio, const gptr buf, int size) +int vio_write(Vio * vio, const gptr buf, int size) { int r; DBUG_ENTER("vio_write"); @@ -136,7 +137,7 @@ int vio_write(st_vio * vio, const gptr buf, int size) } -int vio_blocking(st_vio * vio, my_bool set_blocking_mode) +int vio_blocking(Vio * vio, my_bool set_blocking_mode) { int r=0; DBUG_ENTER("vio_blocking"); @@ -181,7 +182,7 @@ int vio_blocking(st_vio * vio, my_bool set_blocking_mode) } my_bool -vio_is_blocking(st_vio * vio) +vio_is_blocking(Vio * vio) { my_bool r; DBUG_ENTER("vio_is_blocking"); @@ -191,7 +192,7 @@ vio_is_blocking(st_vio * vio) } -int vio_fastsend(st_vio * vio __attribute__((unused))) +int vio_fastsend(Vio * vio __attribute__((unused))) { int r=0; DBUG_ENTER("vio_fastsend"); @@ -217,7 +218,7 @@ int vio_fastsend(st_vio * vio __attribute__((unused))) DBUG_RETURN(r); } -int vio_keepalive(st_vio* vio, my_bool set_keep_alive) +int vio_keepalive(Vio* vio, my_bool set_keep_alive) { int r=0; uint opt = 0; @@ -236,14 +237,14 @@ int vio_keepalive(st_vio* vio, my_bool set_keep_alive) my_bool -vio_should_retry(st_vio * vio __attribute__((unused))) +vio_should_retry(Vio * vio __attribute__((unused))) { int en = errno; return en == EAGAIN || en == EINTR || en == EWOULDBLOCK; } -int vio_close(st_vio * vio) +int vio_close(Vio * vio) { int r; DBUG_ENTER("vio_close"); @@ -276,23 +277,23 @@ int vio_close(st_vio * vio) } -const char *vio_description(st_vio * vio) +const char *vio_description(Vio * vio) { return vio->desc; } -enum enum_vio_type vio_type(st_vio* vio) +enum enum_vio_type vio_type(Vio* vio) { return vio->type; } -my_socket vio_fd(st_vio* vio) +my_socket vio_fd(Vio* vio) { return vio->sd; } -my_bool vio_peer_addr(st_vio * vio, char *buf) +my_bool vio_peer_addr(Vio * vio, char *buf) { DBUG_ENTER("vio_peer_addr"); DBUG_PRINT("enter", ("sd=%d", vio->sd)); @@ -317,7 +318,7 @@ my_bool vio_peer_addr(st_vio * vio, char *buf) } -void vio_in_addr(st_vio *vio, struct in_addr *in) +void vio_in_addr(Vio *vio, struct in_addr *in) { DBUG_ENTER("vio_in_addr"); if (vio->localhost) @@ -330,7 +331,7 @@ void vio_in_addr(st_vio *vio, struct in_addr *in) /* Return 0 if there is data to be read */ -my_bool vio_poll_read(st_vio *vio,uint timeout) +my_bool vio_poll_read(Vio *vio,uint timeout) { #ifndef HAVE_POLL return 0; diff --git a/vio/viossl.c b/vio/viossl.c index 5600bc1a800..696d7d54a29 100644 --- a/vio/viossl.c +++ b/vio/viossl.c @@ -23,10 +23,11 @@ */ #include +#include #include #include -#include +#include #include #include #include @@ -62,7 +63,7 @@ #ifdef HAVE_OPENSSL -void vio_ssl_delete(st_vio * vio) +void vio_ssl_delete(Vio * vio) { /* It must be safe to delete null pointers. */ /* This matches the semantics of C++'s delete operator. */ @@ -74,13 +75,13 @@ void vio_ssl_delete(st_vio * vio) } } -int vio_ssl_errno(st_vio *vio __attribute__((unused))) +int vio_ssl_errno(Vio *vio __attribute__((unused))) { return errno; /* On Win32 this mapped to WSAGetLastError() */ } -int vio_ssl_read(st_vio * vio, gptr buf, int size) +int vio_ssl_read(Vio * vio, gptr buf, int size) { int r; DBUG_ENTER("vio_ssl_read"); @@ -96,7 +97,7 @@ 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_write(Vio * vio, const gptr buf, int size) { int r; DBUG_ENTER("vio_ssl_write"); @@ -112,7 +113,7 @@ int vio_ssl_write(st_vio * vio, const gptr buf, int size) } -int vio_ssl_fastsend(st_vio * vio __attribute__((unused))) +int vio_ssl_fastsend(Vio * vio __attribute__((unused))) { int r=0; DBUG_ENTER("vio_ssl_fastsend"); @@ -138,7 +139,7 @@ int vio_ssl_fastsend(st_vio * vio __attribute__((unused))) DBUG_RETURN(r); } -int vio_ssl_keepalive(st_vio* vio, my_bool set_keep_alive) +int vio_ssl_keepalive(Vio* vio, my_bool set_keep_alive) { int r=0; uint opt = 0; @@ -157,14 +158,14 @@ int vio_ssl_keepalive(st_vio* vio, my_bool set_keep_alive) my_bool -vio_ssl_should_retry(st_vio * vio __attribute__((unused))) +vio_ssl_should_retry(Vio * vio __attribute__((unused))) { int en = errno; return en == EAGAIN || en == EINTR || en == EWOULDBLOCK; } -int vio_ssl_close(st_vio * vio) +int vio_ssl_close(Vio * vio) { int r; DBUG_ENTER("vio_ssl_close"); @@ -191,23 +192,23 @@ int vio_ssl_close(st_vio * vio) } -const char *vio_ssl_description(st_vio * vio) +const char *vio_ssl_description(Vio * vio) { return vio->desc; } -enum enum_vio_type vio_ssl_type(st_vio* vio) +enum enum_vio_type vio_ssl_type(Vio* vio) { return vio->type; } -my_socket vio_ssl_fd(st_vio* vio) +my_socket vio_ssl_fd(Vio* vio) { return vio->sd; } -my_bool vio_ssl_peer_addr(st_vio * vio, char *buf) +my_bool vio_ssl_peer_addr(Vio * vio, char *buf) { DBUG_ENTER("vio_ssl_peer_addr"); DBUG_PRINT("enter", ("sd=%d", vio->sd)); @@ -232,7 +233,7 @@ my_bool vio_ssl_peer_addr(st_vio * vio, char *buf) } -void vio_ssl_in_addr(st_vio *vio, struct in_addr *in) +void vio_ssl_in_addr(Vio *vio, struct in_addr *in) { DBUG_ENTER("vio_ssl_in_addr"); if (vio->localhost) @@ -245,7 +246,7 @@ void vio_ssl_in_addr(st_vio *vio, struct in_addr *in) /* Return 0 if there is data to be read */ -my_bool vio_ssl_poll_read(st_vio *vio,uint timeout) +my_bool vio_ssl_poll_read(Vio *vio,uint timeout) { #ifndef HAVE_POLL return 0; @@ -286,7 +287,7 @@ report_errors() /* FIXME: There are some duplicate code in * sslaccept()/sslconnect() which maybe can be eliminated */ -struct st_vio *sslaccept(struct st_VioSSLAcceptorFd* ptr, struct st_vio* sd) +Vio *sslaccept(struct st_VioSSLAcceptorFd* ptr, Vio* sd) { DBUG_ENTER("sslaccept"); DBUG_PRINT("enter", ("sd=%s ptr=%p", sd->desc,ptr)); @@ -319,7 +320,7 @@ struct st_vio *sslaccept(struct st_VioSSLAcceptorFd* ptr, struct st_vio* sd) DBUG_RETURN(sd); } -struct st_vio *sslconnect(struct st_VioSSLConnectorFd* ptr, struct st_vio* sd) +Vio *sslconnect(struct st_VioSSLConnectorFd* ptr, Vio* sd) { DBUG_ENTER("sslconnect"); DBUG_PRINT("enter", ("sd=%s ptr=%p ctx: %p", sd->desc,ptr,ptr->ssl_context_)); diff --git a/vio/viosslfactories.c b/vio/viosslfactories.c index 2b2eaf4fff5..dfe67b503f8 100644 --- a/vio/viosslfactories.c +++ b/vio/viosslfactories.c @@ -2,7 +2,8 @@ #include #include -#include +#include +#include #ifdef HAVE_OPENSSL