mirror of
https://github.com/MariaDB/server.git
synced 2026-05-06 23:25:34 +02:00
Support for VIO library
Makefile.am: Added vio include/mysql_com.h: Removed ancient defines from Vio++ times include/violite.h: Added vio libmysql/Makefile.shared: Removed sqlobject line with violite.lo libmysql/libmysql.c: Openssl stuff & sons sql/Makefile.am: Added vio sql/mini_client.cc: Added vio sql/mysqld.cc: Added vio sql/net_serv.cc: Added vio sql/sql_parse.cc: Added vio vio/Makefile.am: Removed C++ stuff vio/vio.c: st_vio -> Vio vio/viosocket.c: st_vio -> Vio vio/viossl.c: st_vio -> Vio vio/viosslfactories.c: vio.h-> violite.h
This commit is contained in:
parent
3fc15fd38d
commit
20d04c924b
16 changed files with 249 additions and 114 deletions
|
|
@ -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 \
|
||||
|
|
|
|||
21
vio/vio.c
21
vio/vio.c
|
|
@ -23,10 +23,11 @@
|
|||
|
||||
#define DONT_MAP_VIO
|
||||
#include <global.h>
|
||||
#include <mysql_com.h>
|
||||
#include <violite.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <vio.h>
|
||||
#include <my_sys.h>
|
||||
#include <my_net.h>
|
||||
#include <m_string.h>
|
||||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -24,10 +24,11 @@
|
|||
|
||||
#define DONT_MAP_VIO
|
||||
#include <global.h>
|
||||
#include <mysql_com.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <vio.h>
|
||||
#include <violite.h>
|
||||
#include <my_sys.h>
|
||||
#include <my_net.h>
|
||||
#include <m_string.h>
|
||||
|
|
@ -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;
|
||||
35
vio/viossl.c
35
vio/viossl.c
|
|
@ -23,10 +23,11 @@
|
|||
*/
|
||||
|
||||
#include <global.h>
|
||||
#include <mysql_com.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <vio.h>
|
||||
#include <violite.h>
|
||||
#include <my_sys.h>
|
||||
#include <my_net.h>
|
||||
#include <m_string.h>
|
||||
|
|
@ -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_));
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
#include <global.h>
|
||||
#include <my_sys.h>
|
||||
#include <vio.h>
|
||||
#include <mysql_com.h>
|
||||
#include <violite.h>
|
||||
|
||||
#ifdef HAVE_OPENSSL
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue