summaryrefslogtreecommitdiff
path: root/vio
diff options
context:
space:
mode:
Diffstat (limited to 'vio')
-rw-r--r--vio/vio.c29
-rw-r--r--vio/vio_priv.h4
-rw-r--r--vio/viosocket.c20
-rw-r--r--vio/viosslfactories.c5
4 files changed, 54 insertions, 4 deletions
diff --git a/vio/vio.c b/vio/vio.c
index 21c475f5972..7a98eb2af7b 100644
--- a/vio/vio.c
+++ b/vio/vio.c
@@ -24,6 +24,28 @@
#include "vio_priv.h"
#include "ssl_compat.h"
+PSI_memory_key key_memory_vio_ssl_fd;
+PSI_memory_key key_memory_vio;
+PSI_memory_key key_memory_vio_read_buffer;
+
+#ifdef HAVE_PSI_INTERFACE
+static PSI_memory_info all_vio_memory[]=
+{
+ {&key_memory_vio_ssl_fd, "ssl_fd", 0},
+ {&key_memory_vio, "vio", 0},
+ {&key_memory_vio_read_buffer, "read_buffer", 0},
+};
+
+void init_vio_psi_keys()
+{
+ const char* category= "vio";
+ int count;
+
+ count= array_elements(all_vio_memory);
+ mysql_memory_register(category, all_vio_memory, count);
+}
+#endif
+
#ifdef _WIN32
/**
@@ -81,7 +103,8 @@ static void vio_init(Vio *vio, enum enum_vio_type type,
vio->localhost= flags & VIO_LOCALHOST;
vio->read_timeout= vio->write_timeout= -1;
if ((flags & VIO_BUFFERED_READ) &&
- !(vio->read_buffer= (char*)my_malloc(VIO_READ_BUFFER_SIZE, MYF(MY_WME))))
+ !(vio->read_buffer= (char*)my_malloc(key_memory_vio_read_buffer,
+ VIO_READ_BUFFER_SIZE, MYF(MY_WME))))
flags&= ~VIO_BUFFERED_READ;
#ifdef _WIN32
if (type == VIO_TYPE_NAMEDPIPE)
@@ -218,7 +241,7 @@ Vio *mysql_socket_vio_new(MYSQL_SOCKET mysql_socket, enum enum_vio_type type, ui
my_socket sd= mysql_socket_getfd(mysql_socket);
DBUG_ENTER("mysql_socket_vio_new");
DBUG_PRINT("enter", ("sd: %d", (int)sd));
- if ((vio = (Vio*) my_malloc(sizeof(*vio),MYF(MY_WME))))
+ if ((vio = (Vio*) my_malloc(key_memory_vio, sizeof(*vio), MYF(MY_WME))))
{
vio_init(vio, type, sd, flags);
vio->desc= (vio->type == VIO_TYPE_SOCKET ? "socket" : "TCP/IP");
@@ -248,7 +271,7 @@ Vio *vio_new_win32pipe(HANDLE hPipe)
{
Vio *vio;
DBUG_ENTER("vio_new_handle");
- if ((vio = (Vio*) my_malloc(sizeof(Vio),MYF(MY_WME))))
+ if ((vio = (Vio*) my_malloc(PSI_INSTRUMENT_ME, sizeof(Vio),MYF(MY_WME))))
{
vio_init(vio, VIO_TYPE_NAMEDPIPE, 0, VIO_LOCALHOST);
vio->desc= "named pipe";
diff --git a/vio/vio_priv.h b/vio/vio_priv.h
index 3a0f826e7e8..55c34be9dd7 100644
--- a/vio/vio_priv.h
+++ b/vio/vio_priv.h
@@ -26,6 +26,10 @@
#include <m_string.h>
#include <violite.h>
+extern PSI_memory_key key_memory_vio;
+extern PSI_memory_key key_memory_vio_read_buffer;
+extern PSI_memory_key key_memory_vio_ssl_fd;
+
#ifdef _WIN32
size_t vio_read_pipe(Vio *vio, uchar * buf, size_t size);
size_t vio_write_pipe(Vio *vio, const uchar * buf, size_t size);
diff --git a/vio/viosocket.c b/vio/viosocket.c
index 0820176371d..9cad035161c 100644
--- a/vio/viosocket.c
+++ b/vio/viosocket.c
@@ -645,6 +645,26 @@ enum enum_vio_type vio_type(Vio* vio)
return vio->type;
}
+static const LEX_CSTRING vio_type_names[] =
+{
+ { STRING_WITH_LEN("Error") }, // cannot happen
+ { STRING_WITH_LEN("TCP/IP") },
+ { STRING_WITH_LEN("Socket") },
+ { STRING_WITH_LEN("Named Pipe") },
+ { STRING_WITH_LEN("SSL/TLS") },
+ { STRING_WITH_LEN("Shared Memory") }
+};
+
+const char *vio_type_name(enum enum_vio_type vio_type, size_t *len)
+{
+ int index= vio_type >= FIRST_VIO_TYPE && vio_type <= LAST_VIO_TYPE
+ ? vio_type : 0;
+
+ *len= vio_type_names[index].length;
+ return vio_type_names[index].str;
+}
+
+
my_socket vio_fd(Vio* vio)
{
return mysql_socket_getfd(vio->mysql_socket);
diff --git a/vio/viosslfactories.c b/vio/viosslfactories.c
index 80d1e55f358..d9fcc942a71 100644
--- a/vio/viosslfactories.c
+++ b/vio/viosslfactories.c
@@ -246,7 +246,8 @@ new_VioSSLFd(const char *key_file, const char *cert_file,
vio_check_ssl_init();
if (!(ssl_fd= ((struct st_VioSSLFd*)
- my_malloc(sizeof(struct st_VioSSLFd),MYF(0)))))
+ my_malloc(key_memory_vio_ssl_fd,
+ sizeof(struct st_VioSSLFd), MYF(0)))))
goto err0;
if (!(ssl_fd->ssl_context= SSL_CTX_new(is_client_method ?
SSLv23_client_method() :
@@ -436,7 +437,9 @@ new_VioSSLAcceptorFd(const char *key_file, const char *cert_file,
void free_vio_ssl_acceptor_fd(struct st_VioSSLFd *fd)
{
+ DBUG_ENTER("free_vio_ssl_acceptor_fd");
SSL_CTX_free(fd->ssl_context);
my_free(fd);
+ DBUG_VOID_RETURN;
}
#endif /* HAVE_OPENSSL */