#At file:///home/cpowers/work/dev/dev-wl4896/mysql/ based on revid:chris.powers@stripped
3152 Christopher Powers 2010-07-07
WL#4896 PERFORMANCE_SCHEMA Instrumenting Net IO
Added SOCKET_INSTANCES table, completed instrumentation of socket API
added:
storage/perfschema/table_socket_instances.cc
storage/perfschema/table_socket_instances.h
modified:
include/mysql/psi/mysql_socket.h
scripts/mysql_system_tables.sql
sql/mysqld.cc
sql/mysqld.h
sql/sys_vars.cc
storage/perfschema/CMakeLists.txt
storage/perfschema/ha_perfschema.cc
storage/perfschema/pfs.cc
storage/perfschema/pfs_engine_table.cc
storage/perfschema/pfs_engine_table.h
storage/perfschema/pfs_instr.cc
storage/perfschema/pfs_instr.h
storage/perfschema/pfs_instr_class.cc
storage/perfschema/pfs_server.cc
storage/perfschema/pfs_server.h
storage/perfschema/table_all_instr.cc
storage/perfschema/table_all_instr.h
storage/perfschema/table_events_waits_summary.cc
storage/perfschema/table_events_waits_summary.h
storage/perfschema/table_setup_instruments.cc
storage/perfschema/table_setup_instruments.h
=== modified file 'include/mysql/psi/mysql_socket.h'
--- a/include/mysql/psi/mysql_socket.h 2010-07-01 21:25:57 +0000
+++ b/include/mysql/psi/mysql_socket.h 2010-07-07 19:49:15 +0000
@@ -116,173 +116,173 @@ inline_mysql_end_socket_wait(struct PSI_
#endif
#ifdef HAVE_PSI_INTERFACE
- #define mysql_socket_socketpair(D, T, P, SDS) \
- inline_mysql_socket_socketpair(__FILE__, __LINE__, D, T, P, SDS)
+ #define mysql_socket_socketpair(D, T, P, FDS) \
+ inline_mysql_socket_socketpair(__FILE__, __LINE__, D, T, P, FDS)
#else
- #define mysql_socket_socketpair(D, T, P, SDS) \
- inline_mysql_socket_socketpair(D, T, P, SDS)
+ #define mysql_socket_socketpair(D, T, P, FDS) \
+ inline_mysql_socket_socketpair(D, T, P, FDS)
#endif
#ifdef HAVE_PSI_INTERFACE
- #define mysql_socket_bind(SD, A, L) \
- inline_mysql_socket_bind(__FILE__, __LINE__, SD, A, L)
+ #define mysql_socket_bind(FD, A, L) \
+ inline_mysql_socket_bind(__FILE__, __LINE__, FD, A, L)
#else
- #define mysql_socket_bind(SD, A, L) \
- inline_mysql_socket_bind(SD, A, L)
+ #define mysql_socket_bind(FD, A, L) \
+ inline_mysql_socket_bind(FD, A, L)
#endif
#ifdef HAVE_PSI_INTERFACE
- #define mysql_socket_getsockname(SD, A, LP) \
- inline_mysql_socket_getsockname(__FILE__, __LINE__, SD, A, LP)
+ #define mysql_socket_getsockname(FD, A, LP) \
+ inline_mysql_socket_getsockname(__FILE__, __LINE__, FD, A, LP)
#else
- #define mysql_socket_getsockname(SD, A, LP) \
- inline_mysql_socket_getsockname(SD, A, LP)
+ #define mysql_socket_getsockname(FD, A, LP) \
+ inline_mysql_socket_getsockname(FD, A, LP)
#endif
#ifdef HAVE_PSI_INTERFACE
- #define mysql_socket_connect(SD, A, L) \
- inline_mysql_socket_connect(__FILE__, __LINE__, SD, A, L)
+ #define mysql_socket_connect(FD, A, L) \
+ inline_mysql_socket_connect(__FILE__, __LINE__, FD, A, L)
#else
- #define mysql_socket_connect(SD, A, L) \
- inline_mysql_socket_connect(SD, A, L)
+ #define mysql_socket_connect(FD, A, L) \
+ inline_mysql_socket_connect(FD, A, L)
#endif
#ifdef HAVE_PSI_INTERFACE
- #define mysql_socket_getpeername(SD, A, LP) \
- inline_mysql_socket_getpeername(__FILE__, __LINE__, SD, A, LP)
+ #define mysql_socket_getpeername(FD, A, LP) \
+ inline_mysql_socket_getpeername(__FILE__, __LINE__, FD, A, LP)
#else
- #define mysql_socket_getpeername(SD, A, LP) \
- inline_mysql_socket_getpeername(SD, A, LP)
+ #define mysql_socket_getpeername(FD, A, LP) \
+ inline_mysql_socket_getpeername(FD, A, LP)
#endif
#ifdef HAVE_PSI_INTERFACE
- #define mysql_socket_send(SD, B, N, FL) \
- inline_mysql_socket_send(__FILE__, __LINE__, SD, B, N, FL)
+ #define mysql_socket_send(FD, B, N, FL) \
+ inline_mysql_socket_send(__FILE__, __LINE__, FD, B, N, FL)
#else
- #define mysql_socket_send(SD, B, N, FL) \
- inline_mysql_socket_send(SD, B, N, FL)
+ #define mysql_socket_send(FD, B, N, FL) \
+ inline_mysql_socket_send(FD, B, N, FL)
#endif
#ifdef HAVE_PSI_INTERFACE
- #define mysql_socket_recv(SD, B, N, FL) \
- inline_mysql_socket_recv(__FILE__, __LINE__, SD, B, N, FL)
+ #define mysql_socket_recv(FD, B, N, FL) \
+ inline_mysql_socket_recv(__FILE__, __LINE__, FD, B, N, FL)
#else
- #define mysql_socket_recv(SD, B, N, FL) \
- inline_mysql_socket_recv(SD, B, N, FL)
+ #define mysql_socket_recv(FD, B, N, FL) \
+ inline_mysql_socket_recv(FD, B, N, FL)
#endif
#ifdef HAVE_PSI_INTERFACE
- #define mysql_socket_sendto(SD, B, N, FL, A, L) \
- inline_mysql_socket_sendto(__FILE__, __LINE__, SD, B, N, FL, A, L)
+ #define mysql_socket_sendto(FD, B, N, FL, A, L) \
+ inline_mysql_socket_sendto(__FILE__, __LINE__, FD, B, N, FL, A, L)
#else
- #define mysql_socket_sendto(SD, B, N, FL, A, L) \
- inline_mysql_socket_sendto(SD, B, N, FL, A, L)
+ #define mysql_socket_sendto(FD, B, N, FL, A, L) \
+ inline_mysql_socket_sendto(FD, B, N, FL, A, L)
#endif
#ifdef HAVE_PSI_INTERFACE
- #define mysql_socket_recvfrom(SD, B, N, FL, A, LP) \
- inline_mysql_socket_recvfrom(__FILE__, __LINE__, SD, B, N, FL, A, LP)
+ #define mysql_socket_recvfrom(FD, B, N, FL, A, LP) \
+ inline_mysql_socket_recvfrom(__FILE__, __LINE__, FD, B, N, FL, A, LP)
#else
- #define mysql_socket_recvfrom(SD, B, N, FL, A, LP) \
- inline_mysql_socket_recvfrom(SD, B, N, FL, A, LP)
+ #define mysql_socket_recvfrom(FD, B, N, FL, A, LP) \
+ inline_mysql_socket_recvfrom(FD, B, N, FL, A, LP)
#endif
#ifdef HAVE_PSI_INTERFACE
- #define mysql_socket_sendmsg(SD, M, FL) \
- inline_mysql_socket_sendmsg(__FILE__, __LINE__, SD, M, FL)
+ #define mysql_socket_sendmsg(FD, M, FL) \
+ inline_mysql_socket_sendmsg(__FILE__, __LINE__, FD, M, FL)
#else
- #define mysql_socket_sendmsg(SD, M, FL) \
- inline_mysql_socket_sendmsg(SD, M, FL)
+ #define mysql_socket_sendmsg(FD, M, FL) \
+ inline_mysql_socket_sendmsg(FD, M, FL)
#endif
#ifdef HAVE_PSI_INTERFACE
- #define mysql_socket_recvmsg(SD, M, FL) \
- inline_mysql_socket_recvmsg(__FILE__, __LINE__, SD, M, FL)
+ #define mysql_socket_recvmsg(FD, M, FL) \
+ inline_mysql_socket_recvmsg(__FILE__, __LINE__, FD, M, FL)
#else
- #define_mysql_socket_recvmsg(SD, M, FL) \
- inline_mysql_socket_recvmsg(SD, M, FL)
+ #define_mysql_socket_recvmsg(FD, M, FL) \
+ inline_mysql_socket_recvmsg(FD, M, FL)
#endif
#ifdef HAVE_PSI_INTERFACE
- #define mysql_socket_getsockopt(SD, LV, ON, OP, OL) \
- inline_mysql_socket_getsockopt(__FILE__, __LINE__, SD, LV, ON, OP, OL)
+ #define mysql_socket_getsockopt(FD, LV, ON, OP, OL) \
+ inline_mysql_socket_getsockopt(__FILE__, __LINE__, FD, LV, ON, OP, OL)
#else
- #define mysql_socket_getsockopt(SD, LV, ON, OP, OL) \
- inline_mysql_socket_getsockopt(SD, LV, ON, OP, OL)
+ #define mysql_socket_getsockopt(FD, LV, ON, OP, OL) \
+ inline_mysql_socket_getsockopt(FD, LV, ON, OP, OL)
#endif
#ifdef HAVE_PSI_INTERFACE
- #define mysql_socket_setsockopt(SD, LV, ON, OP, OL) \
- inline_mysql_socket_setsockopt(__FILE__, __LINE__, SD, LV, ON, OP, OL)
+ #define mysql_socket_setsockopt(FD, LV, ON, OP, OL) \
+ inline_mysql_socket_setsockopt(__FILE__, __LINE__, FD, LV, ON, OP, OL)
#else
- #define mysql_socket_setsockopt(SD, LV, ON, OP, OL) \
- inline_mysql_socket_setsockopt(SD, LV, ON, OP, OL)
+ #define mysql_socket_setsockopt(FD, LV, ON, OP, OL) \
+ inline_mysql_socket_setsockopt(FD, LV, ON, OP, OL)
#endif
#ifdef HAVE_PSI_INTERFACE
- #define mysql_socket_listen(SD, N) \
- inline_mysql_socket_listen(__FILE__, __LINE__, SD, N)
+ #define mysql_socket_listen(FD, N) \
+ inline_mysql_socket_listen(__FILE__, __LINE__, FD, N)
#else
- #define mysql_socket_listen(SD, N) \
- inline_mysql_socket_listen(SD, N)
+ #define mysql_socket_listen(FD, N) \
+ inline_mysql_socket_listen(FD, N)
#endif
#ifdef HAVE_PSI_INTERFACE
- #define mysql_socket_accept(SD, A, LP) \
- inline_mysql_socket_accept(__FILE__, __LINE__, SD, A, LP)
+ #define mysql_socket_accept(K, FD, A, LP) \
+ inline_mysql_socket_accept(K, __FILE__, __LINE__, FD, A, LP)
#else
- #define mysql_socket_accept(SD, A, LP) \
- inline_mysql_socket_accept(SD, A, LP)
+ #define mysql_socket_accept(FD, A, LP) \
+ inline_mysql_socket_accept(FD, A, LP)
#endif
#if 0
#ifdef HAVE_PSI_INTERFACE
- #define mysql_socket_accept4(SD, A, LP, FL) \
- inline_mysql_socket_accept4(__FILE__, __LINE__, SD, A, LP, FL)
+ #define mysql_socket_accept4(K, FD, A, LP, FL) \
+ inline_mysql_socket_accept4(K, __FILE__, __LINE__, FD, A, LP, FL)
#else
- #define mysql_socket_accept4(SD, A, LP, FL) \
- inline_mysql_socket_accept4(SD, A, LP, FL)
+ #define mysql_socket_accept4(FD, A, LP, FL) \
+ inline_mysql_socket_accept4(FD, A, LP, FL)
#endif
#endif
#ifdef HAVE_PSI_INTERFACE
- #define mysql_socket_close(SD) \
- inline_mysql_socket_close(__FILE__, __LINE__, SD)
+ #define mysql_socket_close(FD) \
+ inline_mysql_socket_close(__FILE__, __LINE__, FD)
#else
- #define mysql_socket_close(SD) \
- inline_mysql_socket_close(SD)
+ #define mysql_socket_close(FD) \
+ inline_mysql_socket_close(FD)
#endif
#ifdef HAVE_PSI_INTERFACE
- #define mysql_socket_shutdown(SD, H) \
- inline_mysql_socket_shutdown(__FILE__, __LINE__, SD, H)
+ #define mysql_socket_shutdown(FD, H) \
+ inline_mysql_socket_shutdown(__FILE__, __LINE__, FD, H)
#else
- #define mysql_socket_shutdown(SD, H) \
- inline_mysql_socket_shutdown(SD, H)
+ #define mysql_socket_shutdown(FD, H) \
+ inline_mysql_socket_shutdown(FD, H)
#endif
#ifdef HAVE_PSI_INTERFACE
- #define mysql_socket_sockatmark(SD) \
- inline_mysql_socket_sockatmark(__FILE__, __LINE__, SD)
+ #define mysql_socket_sockatmark(FD) \
+ inline_mysql_socket_sockatmark(__FILE__, __LINE__, FD)
#else
- #define mysql_socket_sockatmark(SD) \
- inline_mysql_socket_sockatmark(SD)
+ #define mysql_socket_sockatmark(FD) \
+ inline_mysql_socket_sockatmark(FD)
#endif
#ifdef HAVE_PSI_INTERFACE
- #define mysql_socket_isfdtype(SD, FT) \
- inline_mysql_socket_isfdtype(__FILE__, __LINE__, SD, FT)
+ #define mysql_socket_isfdtype(FD, FT) \
+ inline_mysql_socket_isfdtype(__FILE__, __LINE__, FD, FT)
#else
- #define mysql_socket_isfdtype(SD, FT) \
- inline_mysql_socket_isfdtype(SD, FT)
+ #define mysql_socket_isfdtype(FD, FT) \
+ inline_mysql_socket_isfdtype(FD, FT)
#endif
struct st_mysql_socket
{
/** The real socket identifier. */
- my_socket sd;
+ my_socket fd;
/**
The instrumentation hook.
@@ -301,7 +301,7 @@ struct st_mysql_socket
typedef struct st_mysql_socket MYSQL_SOCKET;
-#define mysql_socket_getsd(SD) ((SD).sd)
+#define mysql_socket_getfd(FD) ((FD).fd)
/** mysql_socket_socket */
@@ -315,10 +315,10 @@ inline_mysql_socket_socket
{
MYSQL_SOCKET mysql_socket = {0, NULL};
#ifdef HAVE_PSI_INTERFACE
- mysql_socket.m_psi = PSI_server ? PSI_server->init_socket(key, &mysql_socket.sd)
+ mysql_socket.m_psi = PSI_server ? PSI_server->init_socket(key, &mysql_socket.fd)
: NULL;
#endif
- mysql_socket.sd= socket(domain, type, protocol);
+ mysql_socket.fd= socket(domain, type, protocol);
return mysql_socket;
}
@@ -337,11 +337,11 @@ inline_mysql_socket_socketpair
#if 0 //TBD
#ifdef HAVE_PSI_INTERFACE
struct PSI_socket_locker *locker= NULL;
- if (likely(PSI_server != NULL))
+ if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
{
locker= PSI_server->get_thread_socket_locker(mysql_socket.m_psi, PSI_SOCKET_CREATE);
- if (likely(locker !=NULL))
- PSI_server->start_socket_wait(locker, src_file, src_line);
+ if (likely(locker !=NULL))
+ PSI_server->start_socket_wait(locker, src_file, src_line);
}
#endif
result= socketpair(int domain, int type, int protocol, int fds[2]);
@@ -366,14 +366,14 @@ inline_mysql_socket_bind
int result;
#ifdef HAVE_PSI_INTERFACE
struct PSI_socket_locker *locker= NULL;
- if (likely(PSI_server != NULL))
+ if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
{
locker= PSI_server->get_thread_socket_locker(mysql_socket.m_psi, PSI_SOCKET_BIND);
if (likely(locker !=NULL))
PSI_server->start_socket_wait(locker, src_file, src_line);
}
#endif
- result= bind(mysql_socket.sd, addr, len);
+ result= bind(mysql_socket.fd, addr, len);
#ifdef HAVE_PSI_INTERFACE
if (likely(locker != NULL))
PSI_server->end_socket_wait(locker);
@@ -394,14 +394,14 @@ inline_mysql_socket_getsockname
int result;
#ifdef HAVE_PSI_INTERFACE
struct PSI_socket_locker *locker= NULL;
- if (likely(PSI_server != NULL))
+ if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
{
locker= PSI_server->get_thread_socket_locker(mysql_socket.m_psi, PSI_SOCKET_BIND);
if (likely(locker !=NULL))
PSI_server->start_socket_wait(locker, src_file, src_line);
}
#endif
- result= getsockname(mysql_socket.sd, addr, len);
+ result= getsockname(mysql_socket.fd, addr, len);
#ifdef HAVE_PSI_INTERFACE
if (likely(locker != NULL))
PSI_server->end_socket_wait(locker);
@@ -422,14 +422,14 @@ inline_mysql_socket_connect
int result;
#ifdef HAVE_PSI_INTERFACE
struct PSI_socket_locker *locker= NULL;
- if (likely(PSI_server != NULL))
+ if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
{
locker= PSI_server->get_thread_socket_locker(mysql_socket.m_psi, PSI_SOCKET_CONNECT);
if (likely(locker !=NULL))
PSI_server->start_socket_wait(locker, src_file, src_line);
}
#endif
- result= connect(mysql_socket.sd, addr, len);
+ result= connect(mysql_socket.fd, addr, len);
#ifdef HAVE_PSI_INTERFACE
if (likely(locker != NULL))
PSI_server->end_socket_wait(locker);
@@ -450,14 +450,14 @@ inline_mysql_socket_getpeername
int result;
#ifdef HAVE_PSI_INTERFACE
struct PSI_socket_locker *locker= NULL;
- if (likely(PSI_server != NULL))
+ if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
{
locker= PSI_server->get_thread_socket_locker(mysql_socket.m_psi, PSI_SOCKET_BIND);
if (likely(locker !=NULL))
PSI_server->start_socket_wait(locker, src_file, src_line);
}
#endif
- result= getpeername(mysql_socket.sd, addr, len);
+ result= getpeername(mysql_socket.fd, addr, len);
#ifdef HAVE_PSI_INTERFACE
if (likely(locker != NULL))
PSI_server->end_socket_wait(locker);
@@ -478,14 +478,14 @@ inline_mysql_socket_send
ssize_t result;
#ifdef HAVE_PSI_INTERFACE
struct PSI_socket_locker *locker= NULL;
- if (likely(PSI_server != NULL))
+ if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
{
locker= PSI_server->get_thread_socket_locker(mysql_socket.m_psi, PSI_SOCKET_SEND);
if (likely(locker !=NULL))
PSI_server->start_socket_wait(locker, src_file, src_line);
}
#endif
- result= send(mysql_socket.sd, buf, n, flags);
+ result= send(mysql_socket.fd, buf, n, flags);
#ifdef HAVE_PSI_INTERFACE
if (likely(locker != NULL))
PSI_server->end_socket_wait(locker);
@@ -506,14 +506,14 @@ inline_mysql_socket_recv
ssize_t result;
#ifdef HAVE_PSI_INTERFACE
struct PSI_socket_locker *locker= NULL;
- if (likely(PSI_server != NULL))
+ if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
{
locker= PSI_server->get_thread_socket_locker(mysql_socket.m_psi, PSI_SOCKET_RECV);
if (likely(locker !=NULL))
PSI_server->start_socket_wait(locker, src_file, src_line);
}
#endif
- result= recv(mysql_socket.sd, buf, n, flags);
+ result= recv(mysql_socket.fd, buf, n, flags);
#ifdef HAVE_PSI_INTERFACE
if (likely(locker != NULL))
PSI_server->end_socket_wait(locker);
@@ -534,14 +534,14 @@ inline_mysql_socket_sendto
ssize_t result;
#ifdef HAVE_PSI_INTERFACE
struct PSI_socket_locker *locker= NULL;
- if (likely(PSI_server != NULL))
+ if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
{
locker= PSI_server->get_thread_socket_locker(mysql_socket.m_psi, PSI_SOCKET_SEND);
if (likely(locker !=NULL))
PSI_server->start_socket_wait(locker, src_file, src_line);
}
#endif
- result= sendto(mysql_socket.sd, buf, n, flags, addr, addr_len);
+ result= sendto(mysql_socket.fd, buf, n, flags, addr, addr_len);
#ifdef HAVE_PSI_INTERFACE
if (likely(locker != NULL))
PSI_server->end_socket_wait(locker);
@@ -562,14 +562,14 @@ inline_mysql_socket_recvfrom
ssize_t result;
#ifdef HAVE_PSI_INTERFACE
struct PSI_socket_locker *locker= NULL;
- if (likely(PSI_server != NULL))
+ if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
{
locker= PSI_server->get_thread_socket_locker(mysql_socket.m_psi, PSI_SOCKET_RECV);
if (likely(locker !=NULL))
PSI_server->start_socket_wait(locker, src_file, src_line);
}
#endif
- result= recvfrom(mysql_socket.sd, buf, n, flags, addr, addr_len);
+ result= recvfrom(mysql_socket.fd, buf, n, flags, addr, addr_len);
#ifdef HAVE_PSI_INTERFACE
if (likely(locker != NULL))
PSI_server->end_socket_wait(locker);
@@ -590,14 +590,14 @@ inline_mysql_socket_sendmsg
ssize_t result;
#ifdef HAVE_PSI_INTERFACE
struct PSI_socket_locker *locker= NULL;
- if (likely(PSI_server != NULL))
+ if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
{
locker= PSI_server->get_thread_socket_locker(mysql_socket.m_psi, PSI_SOCKET_SEND);
if (likely(locker !=NULL))
PSI_server->start_socket_wait(locker, src_file, src_line);
}
#endif
- result= sendmsg(mysql_socket.sd, message, flags);
+ result= sendmsg(mysql_socket.fd, message, flags);
#ifdef HAVE_PSI_INTERFACE
if (likely(locker != NULL))
PSI_server->end_socket_wait(locker);
@@ -618,14 +618,14 @@ inline_mysql_socket_recvmsg
ssize_t result;
#ifdef HAVE_PSI_INTERFACE
struct PSI_socket_locker *locker= NULL;
- if (likely(PSI_server != NULL))
+ if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
{
locker= PSI_server->get_thread_socket_locker(mysql_socket.m_psi, PSI_SOCKET_RECV);
if (likely(locker !=NULL))
PSI_server->start_socket_wait(locker, src_file, src_line);
}
#endif
- result= recvmsg(mysql_socket.sd, message, flags);
+ result= recvmsg(mysql_socket.fd, message, flags);
#ifdef HAVE_PSI_INTERFACE
if (likely(locker != NULL))
PSI_server->end_socket_wait(locker);
@@ -646,14 +646,14 @@ inline_mysql_socket_getsockopt
int result;
#ifdef HAVE_PSI_INTERFACE
struct PSI_socket_locker *locker= NULL;
- if (likely(PSI_server != NULL))
+ if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
{
locker= PSI_server->get_thread_socket_locker(mysql_socket.m_psi, PSI_SOCKET_OPT);
if (likely(locker !=NULL))
PSI_server->start_socket_wait(locker, src_file, src_line);
}
#endif
- result= getsockopt(mysql_socket.sd, level, optname, optval, optlen);
+ result= getsockopt(mysql_socket.fd, level, optname, optval, optlen);
#ifdef HAVE_PSI_INTERFACE
if (likely(locker != NULL))
PSI_server->end_socket_wait(locker);
@@ -674,14 +674,14 @@ inline_mysql_socket_setsockopt
int result;
#ifdef HAVE_PSI_INTERFACE
struct PSI_socket_locker *locker= NULL;
- if (likely(PSI_server != NULL))
+ if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
{
locker= PSI_server->get_thread_socket_locker(mysql_socket.m_psi, PSI_SOCKET_OPT);
if (likely(locker !=NULL))
PSI_server->start_socket_wait(locker, src_file, src_line);
}
#endif
- result= setsockopt(mysql_socket.sd, level, optname, optval, optlen);
+ result= setsockopt(mysql_socket.fd, level, optname, optval, optlen);
#ifdef HAVE_PSI_INTERFACE
if (likely(locker != NULL))
PSI_server->end_socket_wait(locker);
@@ -702,14 +702,14 @@ inline_mysql_socket_listen
int result;
#ifdef HAVE_PSI_INTERFACE
struct PSI_socket_locker *locker= NULL;
- if (likely(PSI_server != NULL))
+ if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
{
locker= PSI_server->get_thread_socket_locker(mysql_socket.m_psi, PSI_SOCKET_CONNECT);
if (likely(locker !=NULL))
PSI_server->start_socket_wait(locker, src_file, src_line);
}
#endif
- result= listen(mysql_socket.sd, n);
+ result= listen(mysql_socket.fd, n);
#ifdef HAVE_PSI_INTERFACE
if (likely(locker != NULL))
PSI_server->end_socket_wait(locker);
@@ -723,27 +723,28 @@ static inline MYSQL_SOCKET
inline_mysql_socket_accept
(
#ifdef HAVE_PSI_INTERFACE
- const char *src_file, uint src_line,
+ PSI_socket_key key, const char *src_file, uint src_line,
#endif
- MYSQL_SOCKET mysql_socket, __SOCKADDR_ARG addr, socklen_t *addr_len)
+ MYSQL_SOCKET socket_listen, __SOCKADDR_ARG addr, socklen_t *addr_len)
{
- MYSQL_SOCKET result = mysql_socket;
- result.sd = 0;
+ MYSQL_SOCKET socket_accept = {0, NULL};
#ifdef HAVE_PSI_INTERFACE
struct PSI_socket_locker *locker= NULL;
- if (likely(PSI_server != NULL))
+ socket_accept.m_psi = PSI_server ? PSI_server->init_socket(key, &socket_accept.fd)
+ : NULL;
+ if (likely(PSI_server != NULL && socket_accept.m_psi != NULL))
{
- locker= PSI_server->get_thread_socket_locker(mysql_socket.m_psi, PSI_SOCKET_CONNECT);
+ locker= PSI_server->get_thread_socket_locker(socket_accept.m_psi, PSI_SOCKET_CONNECT);
if (likely(locker !=NULL))
PSI_server->start_socket_wait(locker, src_file, src_line);
}
#endif
- result.sd= accept(mysql_socket.sd, addr, addr_len);
+ socket_accept.fd= accept(socket_listen.fd, addr, addr_len);
#ifdef HAVE_PSI_INTERFACE
if (likely(locker != NULL))
PSI_server->end_socket_wait(locker);
#endif
- return result;
+ return socket_accept;
}
/** mysql_socket_accept4 */
@@ -753,27 +754,28 @@ static inline MYSQL_SOCKET
inline_mysql_socket_accept4
(
#ifdef HAVE_PSI_INTERFACE
- const char *src_file, uint src_line,
+ PSI_socket_key key, const char *src_file, uint src_line,
#endif
- MYSQL_SOCKET mysql_socket, __SOCKADDR_ARG addr, socklen_t *addr_len, int flags)
+ MYSQL_SOCKET socket_listen, __SOCKADDR_ARG addr, socklen_t *addr_len, int flags)
{
- MYSQL_SOCKET result = mysql_socket;
- result.sd = 0;
+ MYSQL_SOCKET socket_accept = {0, NULL};
#ifdef HAVE_PSI_INTERFACE
struct PSI_socket_locker *locker= NULL;
- if (likely(PSI_server != NULL))
+ socket_accept.m_psi = PSI_server ? PSI_server->init_socket(key, &socket_accept.fd)
+ : NULL;
+ if (likely(PSI_server != NULL && socket_accept.m_psi != NULL))
{
- locker= PSI_server->get_thread_socket_locker(mysql_socket.m_psi, PSI_SOCKET_CONNECT);
+ locker= PSI_server->get_thread_socket_locker(socket_accept.m_psi, PSI_SOCKET_CONNECT);
if (likely(locker !=NULL))
PSI_server->start_socket_wait(locker, src_file, src_line);
}
#endif
- result.sd= accept4(mysql_socket.sd, addr, addr_len, flags);
+ socket_accept.fd= accept4(socket_listen.fd, addr, addr_len, flags);
#ifdef HAVE_PSI_INTERFACE
if (likely(locker != NULL))
PSI_server->end_socket_wait(locker);
#endif
- return result;
+ return socket_accept;
}
#endif
@@ -793,14 +795,14 @@ inline_mysql_socket_close
int result;
#ifdef HAVE_PSI_INTERFACE
struct PSI_socket_locker *locker= NULL;
- if (likely(PSI_server != NULL))
+ if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
{
locker= PSI_server->get_thread_socket_locker(mysql_socket.m_psi, PSI_SOCKET_CLOSE);
if (likely(locker !=NULL))
PSI_server->start_socket_wait(locker, src_file, src_line);
}
#endif
- result= closesocket(mysql_socket.sd);
+ result= closesocket(mysql_socket.fd);
#ifdef HAVE_PSI_INTERFACE
if (likely(locker != NULL))
PSI_server->end_socket_wait(locker);
@@ -821,14 +823,14 @@ inline_mysql_socket_shutdown
int result;
#ifdef HAVE_PSI_INTERFACE
struct PSI_socket_locker *locker= NULL;
- if (likely(PSI_server != NULL))
+ if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
{
locker= PSI_server->get_thread_socket_locker(mysql_socket.m_psi, PSI_SOCKET_SHUTDOWN);
if (likely(locker !=NULL))
PSI_server->start_socket_wait(locker, src_file, src_line);
}
#endif
- result= shutdown(mysql_socket.sd, how);
+ result= shutdown(mysql_socket.fd, how);
#ifdef HAVE_PSI_INTERFACE
if (likely(locker != NULL))
PSI_server->end_socket_wait(locker);
@@ -849,14 +851,14 @@ inline_mysql_socket_sockatmark
int result;
#ifdef HAVE_PSI_INTERFACE
struct PSI_socket_locker *locker= NULL;
- if (likely(PSI_server != NULL))
+ if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
{
locker= PSI_server->get_thread_socket_locker(mysql_socket.m_psi, PSI_SOCKET_STAT);
if (likely(locker !=NULL))
PSI_server->start_socket_wait(locker, src_file, src_line);
}
#endif
- result= sockatmark(mysql_socket.sd);
+ result= sockatmark(mysql_socket.fd);
#ifdef HAVE_PSI_INTERFACE
if (likely(locker != NULL))
PSI_server->end_socket_wait(locker);
@@ -877,14 +879,14 @@ inline_mysql_socket_isfdtype
int result;
#ifdef HAVE_PSI_INTERFACE
struct PSI_socket_locker *locker= NULL;
- if (likely(PSI_server != NULL))
+ if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
{
locker= PSI_server->get_thread_socket_locker(mysql_socket.m_psi, PSI_SOCKET_STAT);
if (likely(locker !=NULL))
PSI_server->start_socket_wait(locker, src_file, src_line);
}
#endif
- result= isfdtype(mysql_socket.sd, fdtype);
+ result= isfdtype(mysql_socket.fd, fdtype);
#ifdef HAVE_PSI_INTERFACE
if (likely(locker != NULL))
PSI_server->end_socket_wait(locker);
=== modified file 'scripts/mysql_system_tables.sql'
--- a/scripts/mysql_system_tables.sql 2010-04-14 16:40:04 +0000
+++ b/scripts/mysql_system_tables.sql 2010-07-07 19:49:15 +0000
@@ -360,6 +360,24 @@ EXECUTE stmt;
DROP PREPARE stmt;
--
+-- TABLE SOCKET_INSTANCES
+--
+
+SET @l1="CREATE TABLE performance_schema.SOCKET_INSTANCES(";
+SET @l2="SOCKET_DESC VARCHAR(512) not null,";
+SET @l3="EVENT_NAME VARCHAR(128) not null,";
+SET @l4="IDENTITY BIGINT not null,";
+SET @l5="OPEN_COUNT INTEGER unsigned not null";
+SET @l6=")ENGINE=PERFORMANCE_SCHEMA;";
+
+SET @cmd=concat(@l1,@l2,@l3,@l4,@l5,@l6);
+
+SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
+PREPARE stmt FROM @str;
+EXECUTE stmt;
+DROP PREPARE stmt;
+
+--
-- TABLE MUTEX_INSTANCES
--
=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc 2010-06-22 23:15:38 +0000
+++ b/sql/mysqld.cc 2010-07-07 19:49:15 +0000
@@ -1078,11 +1078,11 @@ static void close_connections(void)
DBUG_PRINT("quit",("Closing sockets"));
if (!opt_disable_networking )
{
- if (mysql_socket_getsd(ip_sock) != INVALID_SOCKET)
+ if (mysql_socket_getfd(ip_sock) != INVALID_SOCKET)
{
(void) mysql_socket_shutdown(ip_sock, SHUT_RDWR);
(void) mysql_socket_close(ip_sock);
- mysql_socket_getsd(ip_sock)= INVALID_SOCKET;
+ mysql_socket_getfd(ip_sock)= INVALID_SOCKET;
}
}
#ifdef _WIN32
@@ -1110,12 +1110,12 @@ static void close_connections(void)
}
#endif
#ifdef HAVE_SYS_UN_H
- if (mysql_socket_getsd(unix_sock) != INVALID_SOCKET)
+ if (mysql_socket_getfd(unix_sock) != INVALID_SOCKET)
{
(void) mysql_socket_shutdown(unix_sock, SHUT_RDWR);
(void) mysql_socket_close(unix_sock);
(void) unlink(mysqld_unix_port);
- mysql_socket_getsd(unix_sock)= INVALID_SOCKET;
+ mysql_socket_getfd(unix_sock)= INVALID_SOCKET;
}
#endif
end_thr_alarm(0); // Abort old alarms.
@@ -1213,9 +1213,9 @@ static void close_server_sock()
DBUG_ENTER("close_server_sock");
MYSQL_SOCKET tmp_sock;
tmp_sock=ip_sock;
- if (mysql_socket_getsd(tmp_sock) != INVALID_SOCKET)
+ if (mysql_socket_getfd(tmp_sock) != INVALID_SOCKET)
{
- mysql_socket_getsd(ip_sock)= INVALID_SOCKET;
+ mysql_socket_getfd(ip_sock)= INVALID_SOCKET;
DBUG_PRINT("info",("calling shutdown on TCP/IP socket"));
(void) mysql_socket_shutdown(tmp_sock, SHUT_RDWR);
#if defined(__NETWARE__)
@@ -1228,9 +1228,9 @@ static void close_server_sock()
#endif
}
tmp_sock=unix_sock;
- if (mysql_socket_getsd(tmp_sock) != INVALID_SOCKET)
+ if (mysql_socket_getfd(tmp_sock) != INVALID_SOCKET)
{
- mysql_socket_getsd(unix_sock)= INVALID_SOCKET;
+ mysql_socket_getfd(unix_sock)= INVALID_SOCKET;
DBUG_PRINT("info",("calling shutdown on unix socket"));
(void) mysql_socket_shutdown(tmp_sock, SHUT_RDWR);
#if defined(__NETWARE__)
@@ -1865,12 +1865,12 @@ static void network_init(void)
for (a= ai; a != NULL; a= a->ai_next)
{
- ip_sock= mysql_socket_socket(key_socket_server, a->ai_family, a->ai_socktype, a->ai_protocol);
- if (mysql_socket_getsd(ip_sock) != INVALID_SOCKET)
+ ip_sock= mysql_socket_socket(key_socket_network_init, a->ai_family, a->ai_socktype, a->ai_protocol);
+ if (mysql_socket_getfd(ip_sock) != INVALID_SOCKET)
break;
}
- if (mysql_socket_getsd(ip_sock) == INVALID_SOCKET)
+ if (mysql_socket_getfd(ip_sock) == INVALID_SOCKET)
{
DBUG_PRINT("error",("Got error: %d from socket()",socket_errno));
sql_perror(ER_DEFAULT(ER_IPSOCK_ERROR)); /* purecov: tested */
@@ -1999,7 +1999,7 @@ static void network_init(void)
(uint) sizeof(UNIXaddr.sun_path) - 1, mysqld_unix_port);
unireg_abort(1);
}
- if (mysql_socket_getsd((unix_sock= mysql_socket_socket(key_socket_server, AF_UNIX, SOCK_STREAM, 0))) < 0)
+ if (mysql_socket_getfd((unix_sock= mysql_socket_socket(key_socket_network_init, AF_UNIX, SOCK_STREAM, 0))) < 0)
{
sql_perror("Can't start server : UNIX Socket "); /* purecov: inspected */
unireg_abort(1); /* purecov: inspected */
@@ -2012,7 +2012,7 @@ static void network_init(void)
(void) mysql_socket_setsockopt(unix_sock, SOL_SOCKET, SO_REUSEADDR, (char*)&arg,
sizeof(arg));
umask(0);
- if (bind(mysql_socket_getsd(unix_sock), my_reinterpret_cast(struct sockaddr *) (&UNIXaddr),
+ if (bind(mysql_socket_getfd(unix_sock), my_reinterpret_cast(struct sockaddr *) (&UNIXaddr),
sizeof(UNIXaddr)) < 0)
{
sql_perror("Can't start server : Bind on unix socket"); /* purecov: tested */
@@ -4801,7 +4801,7 @@ int mysqld_main(int argc, char **argv)
if (!opt_bootstrap)
mysql_file_delete(key_file_pid, pidfile_name, MYF(MY_WME)); // Not needed anymore
- if (mysql_socket_getsd(unix_sock) != INVALID_SOCKET)
+ if (mysql_socket_getfd(unix_sock) != INVALID_SOCKET)
unlink(mysqld_unix_port);
exit(1);
}
@@ -4868,7 +4868,7 @@ int mysqld_main(int argc, char **argv)
start_handle_manager();
sql_print_information(ER_DEFAULT(ER_STARTUP),my_progname,server_version,
- ((mysql_socket_getsd(unix_sock) == INVALID_SOCKET) ? (char*) ""
+ ((mysql_socket_getfd(unix_sock) == INVALID_SOCKET) ? (char*) ""
: mysqld_unix_port),
mysqld_port,
MYSQL_COMPILATION_COMMENT);
@@ -5351,9 +5351,9 @@ inline void kill_broken_server()
/* hack to get around signals ignored in syscalls for problem OS's */
if (
#if !defined(__NETWARE__)
- mysql_socket_getsd(unix_sock) == INVALID_SOCKET ||
+ mysql_socket_getfd(unix_sock) == INVALID_SOCKET ||
#endif
- (!opt_disable_networking && mysql_socket_getsd(ip_sock) == INVALID_SOCKET))
+ (!opt_disable_networking && mysql_socket_getfd(ip_sock) == INVALID_SOCKET))
{
select_thread_in_use = 0;
/* The following call will never return */
@@ -5383,7 +5383,7 @@ void handle_connections_sockets()
struct pollfd fds[2]; // for ip_sock and unix_sock
#else
fd_set readFDs,clientFDs;
- uint max_used_connection= (uint)(max(mysql_socket_getsd(ip_sock), mysql_socket_getsd(unix_sock))+1);
+ uint max_used_connection= (uint)(max(mysql_socket_getfd(ip_sock), mysql_socket_getfd(unix_sock))+1);
#endif
DBUG_ENTER("handle_connections_sockets");
@@ -5392,29 +5392,29 @@ void handle_connections_sockets()
FD_ZERO(&clientFDs);
#endif
- if (mysql_socket_getsd(ip_sock) != INVALID_SOCKET)
+ if (mysql_socket_getfd(ip_sock) != INVALID_SOCKET)
{
#ifdef HAVE_POLL
- fds[socket_count].fd= mysql_socket_getsd(ip_sock);
+ fds[socket_count].fd= mysql_socket_getfd(ip_sock);
fds[socket_count].events= POLLIN;
socket_count++;
#else
- FD_SET(mysql_socket_getsd(ip_sock), &clientFDs);
+ FD_SET(mysql_socket_getfd(ip_sock), &clientFDs);
#endif
#ifdef HAVE_FCNTL
- ip_flags = fcntl(mysql_socket_getsd(ip_sock), F_GETFL, 0);
+ ip_flags = fcntl(mysql_socket_getfd(ip_sock), F_GETFL, 0);
#endif
}
#ifdef HAVE_SYS_UN_H
#ifdef HAVE_POLL
- fds[socket_count].fd= mysql_socket_getsd(unix_sock);
+ fds[socket_count].fd= mysql_socket_getfd(unix_sock);
fds[socket_count].events= POLLIN;
socket_count++;
#else
- FD_SET(mysql_socket_getsd(unix_sock), &clientFDs);
+ FD_SET(mysql_socket_getfd(unix_sock), &clientFDs);
#endif
#ifdef HAVE_FCNTL
- socket_flags=fcntl(mysql_socket_getsd(unix_sock), F_GETFL, 0);
+ socket_flags=fcntl(mysql_socket_getfd(unix_sock), F_GETFL, 0);
#endif
#endif
@@ -5453,9 +5453,9 @@ void handle_connections_sockets()
{
if (fds[i].revents & POLLIN)
{
- mysql_socket_getsd(sock)= fds[i].fd;
+ mysql_socket_getfd(sock)= fds[i].fd;
#ifdef HAVE_FCNTL
- flags= fcntl(mysql_socket_getsd(sock), F_GETFL, 0);
+ flags= fcntl(mysql_socket_getfd(sock), F_GETFL, 0);
#else
flags= 0;
#endif // HAVE_FCNTL
@@ -5464,7 +5464,7 @@ void handle_connections_sockets()
}
#else // HAVE_POLL
#ifdef HAVE_SYS_UN_H
- if (FD_ISSET(mysql_socket_getsd(unix_sock), &readFDs))
+ if (FD_ISSET(mysql_socket_getfd(unix_sock), &readFDs))
{
sock = unix_sock;
flags= socket_flags;
@@ -5481,24 +5481,24 @@ void handle_connections_sockets()
if (!(test_flags & TEST_BLOCKING))
{
#if defined(O_NONBLOCK)
- fcntl(mysql_socket_getsd(sock), F_SETFL, flags | O_NONBLOCK);
+ fcntl(mysql_socket_getfd(sock), F_SETFL, flags | O_NONBLOCK);
#elif defined(O_NDELAY)
- fcntl(mysql_socket_getsd(sock), F_SETFL, flags | O_NDELAY);
+ fcntl(mysql_socket_getfd(sock), F_SETFL, flags | O_NDELAY);
#endif
}
#endif /* NO_FCNTL_NONBLOCK */
for (uint retry=0; retry < MAX_ACCEPT_RETRY; retry++)
{
size_socket length= sizeof(struct sockaddr_storage);
- new_sock= mysql_socket_accept(sock, (struct sockaddr *)(&cAddr), &length);
+ new_sock= mysql_socket_accept(key_socket_handle_connection, sock, (struct sockaddr *)(&cAddr), &length);
#ifdef __NETWARE__
// TODO: temporary fix, waiting for TCP/IP fix - DEFECT000303149
- if ((mysql_socket_getsd(new_sock) == INVALID_SOCKET) && (socket_errno == EINVAL))
+ if ((mysql_socket_getfd(new_sock) == INVALID_SOCKET) && (socket_errno == EINVAL))
{
kill_server(SIGTERM);
}
#endif
- if (mysql_socket_getsd(new_sock) != INVALID_SOCKET ||
+ if (mysql_socket_getfd(new_sock) != INVALID_SOCKET ||
(socket_errno != SOCKET_EINTR && socket_errno != SOCKET_EAGAIN))
break;
MAYBE_BROKEN_SYSCALL;
@@ -5506,15 +5506,15 @@ void handle_connections_sockets()
if (!(test_flags & TEST_BLOCKING))
{
if (retry == MAX_ACCEPT_RETRY - 1)
- fcntl(mysql_socket_getsd(sock), F_SETFL, flags); // Try without O_NONBLOCK
+ fcntl(mysql_socket_getfd(sock), F_SETFL, flags); // Try without O_NONBLOCK
}
#endif
}
#if !defined(NO_FCNTL_NONBLOCK)
if (!(test_flags & TEST_BLOCKING))
- fcntl(mysql_socket_getsd(sock), F_SETFL, flags);
+ fcntl(mysql_socket_getfd(sock), F_SETFL, flags);
#endif
- if (mysql_socket_getsd(new_sock) == INVALID_SOCKET)
+ if (mysql_socket_getfd(new_sock) == INVALID_SOCKET)
{
if ((error_count++ & 255) == 0) // This can happen often
sql_perror("Error in accept");
@@ -5526,11 +5526,11 @@ void handle_connections_sockets()
#ifdef HAVE_LIBWRAP
{
- if (mysql_socket_getsd(sock) == mysql_socket_getsd(ip_sock))
+ if (mysql_socket_getfd(sock) == mysql_socket_getfd(ip_sock))
{
struct request_info req;
signal(SIGCHLD, SIG_DFL);
- request_init(&req, RQ_DAEMON, libwrapName, RQ_FILE, mysql_socket_getsd(new_sock), NULL); //TBD cwp
+ request_init(&req, RQ_DAEMON, libwrapName, RQ_FILE, mysql_socket_getfd(new_sock), NULL); //TBD cwp
my_fromhost(&req);
if (!my_hosts_access(&req))
{
@@ -5583,10 +5583,10 @@ void handle_connections_sockets()
(void) mysql_socket_close(new_sock);
continue;
}
- if (!(vio_tmp=vio_new(mysql_socket_getsd(new_sock), //TBD cwp
- mysql_socket_getsd(sock) == mysql_socket_getsd(unix_sock) ? VIO_TYPE_SOCKET :
+ if (!(vio_tmp=vio_new(mysql_socket_getfd(new_sock), //TBD cwp
+ mysql_socket_getfd(sock) == mysql_socket_getfd(unix_sock) ? VIO_TYPE_SOCKET :
VIO_TYPE_TCPIP,
- mysql_socket_getsd(sock) == mysql_socket_getsd(unix_sock) ? VIO_LOCALHOST: 0)) ||
+ mysql_socket_getfd(sock) == mysql_socket_getfd(unix_sock) ? VIO_LOCALHOST: 0)) ||
my_net_init(&thd->net,vio_tmp))
{
/*
@@ -5604,7 +5604,7 @@ void handle_connections_sockets()
delete thd;
continue;
}
- if (mysql_socket_getsd(sock) == mysql_socket_getsd(unix_sock))
+ if (mysql_socket_getfd(sock) == mysql_socket_getfd(unix_sock))
thd->security_ctx->host=(char*) my_localhost;
create_new_thread(thd);
@@ -7054,7 +7054,7 @@ static int mysql_init_variables(void)
character_set_filesystem= &my_charset_bin;
opt_specialflag= SPECIAL_ENGLISH;
- mysql_socket_getsd(unix_sock)= mysql_socket_getsd(ip_sock)= INVALID_SOCKET;
+ mysql_socket_getfd(unix_sock)= mysql_socket_getfd(ip_sock)= INVALID_SOCKET;
mysql_home_ptr= mysql_home;
pidfile_name_ptr= pidfile_name;
log_error_file_ptr= log_error_file;
@@ -8222,12 +8222,12 @@ static PSI_file_info all_server_files[]=
{ &key_file_init, "init", 0}
};
-PSI_socket_key key_socket_server, key_socket_TBD;
+PSI_socket_key key_socket_network_init, key_socket_handle_connection;
static PSI_socket_info all_server_sockets[]=
{
- { &key_socket_server, "server", 0},
- { &key_socket_TBD, "TBD", 0}
+ { &key_socket_network_init, "network_init", 0},
+ { &key_socket_handle_connection, "handle_connection", 0}
};
/**
=== modified file 'sql/mysqld.h'
--- a/sql/mysqld.h 2010-06-22 23:15:38 +0000
+++ b/sql/mysqld.h 2010-07-07 19:49:15 +0000
@@ -280,7 +280,7 @@ extern PSI_file_key key_file_binlog, key
key_file_pid, key_file_relay_log_info, key_file_send_file, key_file_tclog,
key_file_trg, key_file_trn, key_file_init;
-extern PSI_socket_key key_socket_server, key_socket_TBD;
+extern PSI_socket_key key_socket_network_init, key_socket_handle_connection;
void init_server_psi_keys();
#endif /* HAVE_PSI_INTERFACE */
=== modified file 'sql/sys_vars.cc'
--- a/sql/sys_vars.cc 2010-06-17 16:58:30 +0000
+++ b/sql/sys_vars.cc 2010-07-07 19:49:15 +0000
@@ -133,6 +133,22 @@ static Sys_var_ulong Sys_pfs_max_file_in
DEFAULT(PFS_MAX_FILE),
BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
+static Sys_var_ulong Sys_pfs_max_sockets(
+ "performance_schema_max_sockets",
+ "Maximum number of opened instrumented sockets.",
+ READ_ONLY GLOBAL_VAR(pfs_param.m_socket_sizing),
+ CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 1024*1024),
+ DEFAULT(PFS_MAX_SOCKETS),
+ BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
+
+static Sys_var_ulong Sys_pfs_max_socket_classes(
+ "performance_schema_max_socket_classes",
+ "Maximum number of socket instruments.",
+ READ_ONLY GLOBAL_VAR(pfs_param.m_socket_class_sizing),
+ CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 256),
+ DEFAULT(PFS_MAX_SOCKET_CLASS),
+ BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
+
static Sys_var_ulong Sys_pfs_max_mutex_classes(
"performance_schema_max_mutex_classes",
"Maximum number of mutex instruments.",
=== modified file 'storage/perfschema/CMakeLists.txt'
--- a/storage/perfschema/CMakeLists.txt 2010-04-19 12:26:29 +0000
+++ b/storage/perfschema/CMakeLists.txt 2010-07-07 19:49:15 +0000
@@ -41,6 +41,7 @@ SET(PERFSCHEMA_SOURCES ha_perfschema.h
table_events_waits_summary.h
table_file_instances.h
table_file_summary.h
+ table_socket_instances.h
table_performance_timers.h
table_processlist.h
table_setup_consumers.h
@@ -63,6 +64,7 @@ SET(PERFSCHEMA_SOURCES ha_perfschema.h
table_events_waits_summary.cc
table_file_instances.cc
table_file_summary.cc
+ table_socket_instances.cc
table_performance_timers.cc
table_processlist.cc
table_setup_consumers.cc
=== modified file 'storage/perfschema/ha_perfschema.cc'
--- a/storage/perfschema/ha_perfschema.cc 2010-06-03 13:30:54 +0000
+++ b/storage/perfschema/ha_perfschema.cc 2010-07-07 19:49:15 +0000
@@ -125,6 +125,8 @@ static struct st_mysql_show_var pfs_stat
(char*) &file_lost, SHOW_LONG},
{"Performance_schema_file_handles_lost",
(char*) &file_handle_lost, SHOW_LONG},
+ {"Performance_schema_socket_instances_lost",
+ (char*) &socket_lost, SHOW_LONG},
{"Performance_schema_locker_lost",
(char*) &locker_lost, SHOW_LONG},
/* table shares, can be flushed */
=== modified file 'storage/perfschema/pfs.cc'
--- a/storage/perfschema/pfs.cc 2010-06-22 23:15:38 +0000
+++ b/storage/perfschema/pfs.cc 2010-07-07 19:49:15 +0000
@@ -938,7 +938,21 @@ static void destroy_cond_v1(PSI_cond* co
static PSI_socket*
init_socket_v1(PSI_socket_key key, const void *identity)
{
- INIT_BODY_V1(socket, key, identity);
+// INIT_BODY_V1(socket, key, identity);
+ PFS_socket_class *klass;
+ PFS_socket *pfs;
+ PFS_thread *pfs_thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
+ if (unlikely(pfs_thread == NULL))
+ return NULL;
+ if (! pfs_thread->m_enabled)
+ return NULL;
+ klass= find_socket_class(key);
+ if (unlikely(klass == NULL))
+ return NULL;
+ if (! klass->m_enabled)
+ return NULL;
+ pfs= create_socket(klass, identity);
+ return reinterpret_cast<PSI_socket *> (pfs);
}
static void destroy_socket_v1(PSI_socket* socket)
@@ -1181,10 +1195,12 @@ static PSI_rwlock_locker*
get_thread_rwlock_locker_v1(PSI_rwlock *rwlock, PSI_rwlock_operation op)
{
PFS_rwlock *pfs_rwlock= reinterpret_cast<PFS_rwlock*> (rwlock);
+
DBUG_ASSERT(static_cast<int> (op) >= 0);
DBUG_ASSERT(static_cast<uint> (op) < array_elements(rwlock_operation_map));
DBUG_ASSERT(pfs_rwlock != NULL);
DBUG_ASSERT(pfs_rwlock->m_class != NULL);
+
if (! flag_events_waits_current)
return NULL;
if (! pfs_rwlock->m_class->m_enabled)
@@ -1507,7 +1523,57 @@ get_thread_file_descriptor_locker_v1(Fil
static PSI_socket_locker*
get_thread_socket_locker_v1(PSI_socket *socket, PSI_socket_operation op)
{
- return NULL;
+ PFS_socket *pfs_socket= reinterpret_cast<PFS_socket*> (socket);
+
+ DBUG_ASSERT(static_cast<int> (op) >= 0);
+ DBUG_ASSERT(static_cast<uint> (op) < array_elements(socket_operation_map));
+ DBUG_ASSERT(pfs_socket != NULL);
+ DBUG_ASSERT(pfs_socket->m_class != NULL);
+
+ if (! flag_events_waits_current)
+ return NULL;
+
+ if (! pfs_socket->m_class->m_enabled)
+ return NULL;
+
+ PFS_thread *pfs_thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
+
+ if (unlikely(pfs_thread == NULL))
+ return NULL;
+
+ if (! pfs_thread->m_enabled)
+ return NULL;
+
+ if (unlikely(pfs_thread->m_wait_locker_count >= LOCKER_STACK_SIZE))
+ {
+ locker_lost++;
+ return NULL;
+ }
+
+ PFS_wait_locker *pfs_locker= &pfs_thread->m_wait_locker_stack[pfs_thread->m_wait_locker_count];
+ pfs_locker->m_waits_current.m_wait_class= NO_WAIT_CLASS;
+
+ pfs_locker->m_target.m_socket= pfs_socket;
+ pfs_locker->m_waits_current.m_thread= pfs_thread;
+ pfs_locker->m_waits_current.m_class= pfs_socket->m_class;
+
+ if (pfs_socket->m_class->m_timed)
+ {
+ pfs_locker->m_timer_name= wait_timer;
+ pfs_locker->m_waits_current.m_timer_state= TIMER_STATE_STARTING;
+ }
+ else
+ pfs_locker->m_waits_current.m_timer_state= TIMER_STATE_UNTIMED;
+
+ pfs_locker->m_waits_current.m_object_instance_addr= pfs_socket; // TBD
+ pfs_locker->m_waits_current.m_object_name= pfs_socket->m_socket_desc;
+ pfs_locker->m_waits_current.m_object_name_length= pfs_socket->m_socket_desc_length;
+ pfs_locker->m_waits_current.m_event_id= pfs_thread->m_event_id++;
+ pfs_locker->m_waits_current.m_operation= socket_operation_map[static_cast<int>(op)];
+ pfs_locker->m_waits_current.m_wait_class= WAIT_CLASS_FILE;
+
+ pfs_thread->m_wait_locker_count++;
+ return reinterpret_cast<PSI_socket_locker*> (pfs_locker);
}
static void unlock_mutex_v1(PSI_thread * thread, PSI_mutex *mutex)
@@ -2092,10 +2158,10 @@ static void end_socket_wait_v1(PSI_socke
PFS_socket *socket= pfs_locker->m_target.m_socket;
ulonglong wait_time= wait->m_timer_end - wait->m_timer_start;
- //aggregate_single_stat_chain(&socket->m_wait_stat, wait_time);
- //stat= find_per_thread_socket_class_wait_stat(wait->m_thread,
- // socket->m_class);
- //aggregate_single_stat_chain(stat, wait_time);
+ aggregate_single_stat_chain(&socket->m_wait_stat, wait_time);
+ stat= find_per_thread_socket_class_wait_stat(wait->m_thread,
+ socket->m_class);
+ aggregate_single_stat_chain(stat, wait_time);
PFS_socket_class *klass= socket->m_class;
=== modified file 'storage/perfschema/pfs_engine_table.cc'
--- a/storage/perfschema/pfs_engine_table.cc 2010-06-03 13:30:54 +0000
+++ b/storage/perfschema/pfs_engine_table.cc 2010-07-07 19:49:15 +0000
@@ -31,6 +31,7 @@
#include "table_sync_instances.h"
#include "table_file_instances.h"
#include "table_file_summary.h"
+#include "table_socket_instances.h"
/* For show status */
#include "pfs_column_values.h"
@@ -65,6 +66,7 @@ static PFS_engine_table_share *all_share
&table_rwlock_instances::m_share,
&table_cond_instances::m_share,
&table_file_instances::m_share,
+ &table_socket_instances::m_share,
NULL
};
@@ -742,11 +744,24 @@ bool pfs_show_status(handlerton *hton, T
size= table_max * sizeof(PFS_table);
total_memory+= size;
break;
+ case 50:
+ name= "SOCKET_INSTANCES.ROW_SIZE";
+ size= sizeof(PFS_socket);
+ break;
+ case 51:
+ name= "SOCKET_INSTANCES.ROW_COUNT";
+ size= socket_max;
+ break;
+ case 52:
+ name= "SOCKET_INSTANCES.MEMORY";
+ size= socket_max * sizeof(PFS_socket);
+ total_memory+= size;
+ break;
/*
This case must be last,
for aggregation in total_memory.
*/
- case 50:
+ case 53:
name= "PERFORMANCE_SCHEMA.MEMORY";
size= total_memory;
/* This will fail if something is not advertised here */
=== modified file 'storage/perfschema/pfs_engine_table.h'
--- a/storage/perfschema/pfs_engine_table.h 2010-06-03 13:30:54 +0000
+++ b/storage/perfschema/pfs_engine_table.h 2010-07-07 19:49:15 +0000
@@ -299,6 +299,7 @@ struct PFS_instrument_view_constants
static const uint VIEW_RWLOCK= 2;
static const uint VIEW_COND= 3;
static const uint VIEW_FILE= 4;
+ static const uint VIEW_SOCKET= 5;
};
struct PFS_object_view_constants
=== modified file 'storage/perfschema/pfs_instr.cc'
--- a/storage/perfschema/pfs_instr.cc 2010-06-22 23:15:38 +0000
+++ b/storage/perfschema/pfs_instr.cc 2010-07-07 19:49:15 +0000
@@ -136,6 +136,7 @@ static volatile uint32 thread_internal_i
static uint per_thread_rwlock_class_start;
static uint per_thread_cond_class_start;
static uint per_thread_file_class_start;
+static uint per_thread_socket_class_start;
static uint thread_instr_class_waits_sizing;
static PFS_single_stat_chain *thread_instr_class_waits_array= NULL;
@@ -174,6 +175,8 @@ int init_instruments(const PFS_global_pa
table_lost= 0;
thread_max= param->m_thread_sizing;
thread_lost= 0;
+ socket_max= param->m_socket_sizing;
+ socket_lost= 0;
events_waits_history_per_thread= param->m_events_waits_history_sizing;
thread_history_sizing= param->m_thread_sizing
@@ -184,9 +187,12 @@ int init_instruments(const PFS_global_pa
+ param->m_rwlock_class_sizing;
per_thread_file_class_start= per_thread_cond_class_start
+ param->m_cond_class_sizing;
- instr_class_per_thread= per_thread_file_class_start
+ per_thread_socket_class_start= per_thread_file_class_start
+ param->m_file_class_sizing;
+ instr_class_per_thread= per_thread_socket_class_start
+ + param->m_socket_class_sizing;
+
thread_instr_class_waits_sizing= param->m_thread_sizing
* instr_class_per_thread;
@@ -195,6 +201,7 @@ int init_instruments(const PFS_global_pa
cond_array= NULL;
file_array= NULL;
file_handle_array= NULL;
+ socket_array= NULL;
table_array= NULL;
thread_array= NULL;
thread_history_array= NULL;
@@ -236,6 +243,13 @@ int init_instruments(const PFS_global_pa
return 1;
}
+ if (socket_max > 0)
+ {
+ socket_array= PFS_MALLOC_ARRAY(socket_max, PFS_socket, MYF(MY_ZEROFILL));
+ if (unlikely(socket_array == NULL))
+ return 1;
+ }
+
if (table_max > 0)
{
table_array= PFS_MALLOC_ARRAY(table_max, PFS_table, MYF(MY_ZEROFILL));
@@ -382,6 +396,28 @@ find_per_thread_file_class_wait_stat(PFS
return stat;
}
+/**
+ Find the per-thread wait statistics for a socket class.
+ @param thread input thread
+ @param klass socket class
+ @return the per thread per socket class wait stat
+*/
+PFS_single_stat_chain *
+find_per_thread_socket_class_wait_stat(PFS_thread *thread,
+ PFS_socket_class *klass)
+{
+ PFS_single_stat_chain *stat;
+ uint index;
+
+ DBUG_ASSERT(thread != NULL);
+ DBUG_ASSERT(klass != NULL);
+ index= klass->m_index;
+ DBUG_ASSERT(index < socket_class_max);
+
+ stat= &(thread->m_instr_class_wait_stats[per_thread_socket_class_start + index]);
+ return stat;
+}
+
/** Reset the wait statistics per thread. */
void reset_per_thread_wait_stat(void)
{
@@ -410,6 +446,9 @@ void cleanup_instruments(void)
pfs_free(file_handle_array);
file_handle_array= NULL;
file_handle_max= 0;
+ pfs_free(socket_array);
+ socket_array= NULL;
+ socket_max= 0;
pfs_free(table_array);
table_array= NULL;
table_max= 0;
@@ -1063,7 +1102,7 @@ void destroy_table(PFS_table *pfs)
@param identity the socket address
@return a socket instance, or NULL
*/
-PFS_socket* create_socket(PFS_socket_class *klass, const void *identity) // TBD
+PFS_socket* create_socket(PFS_socket_class *klass, const void *identity)
{
PFS_scan scan;
uint random= randomized_index(identity, socket_max);
=== modified file 'storage/perfschema/pfs_instr.h'
--- a/storage/perfschema/pfs_instr.h 2010-06-22 23:15:38 +0000
+++ b/storage/perfschema/pfs_instr.h 2010-07-07 19:49:15 +0000
@@ -134,8 +134,10 @@ struct PFS_socket : public PFS_instr
{
/** Socket identity, typically int */
const void *m_identity;
- /** Socket data. */ // TBD
- char m_socketaddr[14];
+ /** Socket description. */
+ char m_socket_desc[14]; // TBD
+ /** Socket description length in bytes */
+ uint m_socket_desc_length;
/** Socket class. */
PFS_socket_class *m_class;
/** Socket usage statistics. */
@@ -257,6 +259,10 @@ PFS_single_stat_chain*
find_per_thread_file_class_wait_stat(PFS_thread *thread,
PFS_file_class *klass);
+PFS_single_stat_chain*
+find_per_thread_socket_class_wait_stat(PFS_thread *thread,
+ PFS_socket_class *klass);
+
int init_instruments(const PFS_global_param *param);
void cleanup_instruments();
int init_file_hash();
=== modified file 'storage/perfschema/pfs_instr_class.cc'
--- a/storage/perfschema/pfs_instr_class.cc 2010-06-22 23:15:38 +0000
+++ b/storage/perfschema/pfs_instr_class.cc 2010-07-07 19:49:15 +0000
@@ -353,8 +353,7 @@ int init_socket_class(uint socket_class_
if (socket_class_max > 0)
{
- socket_class_array= PFS_MALLOC_ARRAY(socket_class_max, PFS_socket_class,
- MYF(MY_ZEROFILL));
+ socket_class_array= PFS_MALLOC_ARRAY(socket_class_max, PFS_socket_class, MYF(MY_ZEROFILL));
if (unlikely(socket_class_array == NULL))
return 1;
}
@@ -748,8 +747,18 @@ PFS_socket_key register_socket_class(con
uint32 index;
PFS_socket_class *entry;
- REGISTER_CLASS_BODY_PART(index, socket_class_array, socket_class_max,
- name, name_length)
+// REGISTER_CLASS_BODY_PART(index, socket_class_array, socket_class_max, name, name_length)
+
+ for (index= 0; index < socket_class_max; index++)
+ {
+ entry= &socket_class_array[index];
+ if ((entry->m_name_length == name_length) &&
+ (strncmp(entry->m_name, name, name_length) == 0))
+ {
+ DBUG_ASSERT(entry->m_flags == flags);
+ return (index + 1);
+ }
+ }
index= PFS_atomic::add_u32(&socket_class_dirty_count, 1);
@@ -776,7 +785,10 @@ PFS_socket_key register_socket_class(con
*/
PFS_socket_class *find_socket_class(PFS_socket_key key)
{
- FIND_CLASS_BODY(key, socket_class_allocated_count, socket_class_array);
+// FIND_CLASS_BODY(key, socket_class_allocated_count, socket_class_array);
+ if ((key == 0) || (key > socket_class_allocated_count))
+ return NULL;
+ return &socket_class_array[key - 1];
}
PFS_socket_class *sanitize_socket_class(PFS_socket_class *unsafe)
=== modified file 'storage/perfschema/pfs_server.cc'
--- a/storage/perfschema/pfs_server.cc 2010-06-04 20:20:13 +0000
+++ b/storage/perfschema/pfs_server.cc 2010-07-07 19:49:15 +0000
@@ -65,6 +65,7 @@ initialize_performance_schema(const PFS_
init_thread_class(param->m_thread_class_sizing) ||
init_table_share(param->m_table_share_sizing) ||
init_file_class(param->m_file_class_sizing) ||
+ init_socket_class(param->m_socket_class_sizing) ||
init_instruments(param) ||
init_events_waits_history_long(
param->m_events_waits_history_long_sizing) ||
@@ -109,6 +110,7 @@ static void cleanup_performance_schema(v
cleanup_thread_class();
cleanup_table_share();
cleanup_file_class();
+ cleanup_socket_class();
cleanup_events_waits_history_long();
cleanup_table_share_hash();
cleanup_file_hash();
=== modified file 'storage/perfschema/pfs_server.h'
--- a/storage/perfschema/pfs_server.h 2010-06-03 13:30:54 +0000
+++ b/storage/perfschema/pfs_server.h 2010-07-07 19:49:15 +0000
@@ -54,6 +54,12 @@
#ifndef PFS_MAX_FILE_HANDLE
#define PFS_MAX_FILE_HANDLE 32768
#endif
+#ifndef PFS_MAX_SOCKETS
+ #define PFS_MAX_SOCKETS 10000
+#endif
+#ifndef PFS_MAX_SOCKET_CLASS
+ #define PFS_MAX_SOCKET_CLASS 50
+#endif
#ifndef PFS_MAX_TABLE_SHARE
#define PFS_MAX_TABLE_SHARE 50000
#endif
@@ -83,6 +89,8 @@ struct PFS_global_param
ulong m_table_sizing;
ulong m_file_sizing;
ulong m_file_handle_sizing;
+ ulong m_socket_sizing;
+ ulong m_socket_class_sizing;
ulong m_events_waits_history_sizing;
ulong m_events_waits_history_long_sizing;
};
=== modified file 'storage/perfschema/table_all_instr.cc'
--- a/storage/perfschema/table_all_instr.cc 2010-06-03 13:30:54 +0000
+++ b/storage/perfschema/table_all_instr.cc 2010-07-07 19:49:15 +0000
@@ -40,6 +40,7 @@ int table_all_instr::rnd_next(void)
PFS_rwlock *rwlock;
PFS_cond *cond;
PFS_file *file;
+ PFS_socket *socket;
for (m_pos.set_at(&m_next_pos);
m_pos.has_more_view();
@@ -94,6 +95,18 @@ int table_all_instr::rnd_next(void)
}
}
break;
+ case pos_all_instr::VIEW_SOCKET:
+ for ( ; m_pos.m_index_2 < socket_max; m_pos.m_index_2++)
+ {
+ socket= &socket_array[m_pos.m_index_2];
+ if (socket->m_lock.is_populated())
+ {
+ make_socket_row(socket);
+ m_next_pos.set_after(&m_pos);
+ return 0;
+ }
+ }
+ break;
}
}
@@ -106,6 +119,7 @@ int table_all_instr::rnd_pos(const void
PFS_rwlock *rwlock;
PFS_cond *cond;
PFS_file *file;
+ PFS_socket *socket;
set_position(pos);
@@ -146,6 +160,15 @@ int table_all_instr::rnd_pos(const void
return 0;
}
break;
+ case pos_all_instr::VIEW_SOCKET:
+ DBUG_ASSERT(m_pos.m_index_2 < socket_max);
+ socket= &socket_array[m_pos.m_index_2];
+ if (socket->m_lock.is_populated())
+ {
+ make_socket_row(socket);
+ return 0;
+ }
+ break;
}
return HA_ERR_RECORD_DELETED;
@@ -169,6 +192,7 @@ int table_all_instr_class::rnd_next(void
PFS_rwlock_class *rwlock_class;
PFS_cond_class *cond_class;
PFS_file_class *file_class;
+ PFS_socket_class *socket_class;
for (m_pos.set_at(&m_next_pos);
m_pos.has_more_view();
@@ -211,6 +235,15 @@ int table_all_instr_class::rnd_next(void
return 0;
}
break;
+ case pos_all_instr_class::VIEW_SOCKET:
+ socket_class= find_socket_class(m_pos.m_index_2);
+ if (socket_class)
+ {
+ make_instr_row(socket_class);
+ m_next_pos.set_after(&m_pos);
+ return 0;
+ }
+ break;
}
}
@@ -223,6 +256,7 @@ int table_all_instr_class::rnd_pos(const
PFS_rwlock_class *rwlock_class;
PFS_cond_class *cond_class;
PFS_file_class *file_class;
+ PFS_socket_class *socket_class;
set_position(pos);
switch (m_pos.m_index_1) {
@@ -258,6 +292,14 @@ int table_all_instr_class::rnd_pos(const
return 0;
}
break;
+ case pos_all_instr_class::VIEW_SOCKET:
+ socket_class= find_socket_class(m_pos.m_index_2);
+ if (socket_class)
+ {
+ make_instr_row(socket_class);
+ return 0;
+ }
+ break;
}
return HA_ERR_RECORD_DELETED;
=== modified file 'storage/perfschema/table_all_instr.h'
--- a/storage/perfschema/table_all_instr.h 2010-06-03 13:30:54 +0000
+++ b/storage/perfschema/table_all_instr.h 2010-07-07 19:49:15 +0000
@@ -45,7 +45,7 @@ struct pos_all_instr_class : public PFS_
}
inline bool has_more_view(void)
- { return (m_index_1 <= VIEW_FILE); }
+ { return (m_index_1 <= VIEW_SOCKET); }
inline void next_view(void)
{
@@ -105,7 +105,7 @@ struct pos_all_instr : public PFS_double
}
inline bool has_more_view(void)
- { return (m_index_1 <= VIEW_FILE); }
+ { return (m_index_1 <= VIEW_SOCKET); }
inline void next_view(void)
{
@@ -157,6 +157,11 @@ protected:
@param pfs the file instance
*/
virtual void make_file_row(PFS_file *pfs)= 0;
+ /**
+ Build a row in the socket instance view.
+ @param pfs the socket instance
+ */
+ virtual void make_socket_row(PFS_socket *pfs)= 0;
/** Current position. */
pos_all_instr m_pos;
=== modified file 'storage/perfschema/table_events_waits_summary.cc'
--- a/storage/perfschema/table_events_waits_summary.cc 2010-06-03 13:30:54 +0000
+++ b/storage/perfschema/table_events_waits_summary.cc 2010-07-07 19:49:15 +0000
@@ -118,6 +118,7 @@ int table_events_waits_summary_by_thread
PFS_rwlock_class *rwlock_class;
PFS_cond_class *cond_class;
PFS_file_class *file_class;
+ PFS_socket_class *socket_class;
for (m_pos.set_at(&m_next_pos);
m_pos.has_more_thread();
@@ -165,6 +166,15 @@ int table_events_waits_summary_by_thread
return 0;
}
break;
+ case pos_events_waits_summary_by_thread_by_event_name::VIEW_SOCKET:
+ socket_class= find_socket_class(m_pos.m_index_3);
+ if (socket_class)
+ {
+ make_socket_row(thread, socket_class);
+ m_next_pos.set_after(&m_pos);
+ return 0;
+ }
+ break;
}
}
}
@@ -181,6 +191,7 @@ table_events_waits_summary_by_thread_by_
PFS_rwlock_class *rwlock_class;
PFS_cond_class *cond_class;
PFS_file_class *file_class;
+ PFS_socket_class *socket_class;
set_position(pos);
DBUG_ASSERT(m_pos.m_index_1 < thread_max);
@@ -222,6 +233,14 @@ table_events_waits_summary_by_thread_by_
return 0;
}
break;
+ case pos_events_waits_summary_by_thread_by_event_name::VIEW_SOCKET:
+ socket_class= find_socket_class(m_pos.m_index_3);
+ if (socket_class)
+ {
+ make_socket_row(thread, socket_class);
+ return 0;
+ }
+ break;
}
return HA_ERR_RECORD_DELETED;
}
@@ -290,6 +309,14 @@ void table_events_waits_summary_by_threa
make_instr_row(thread, klass, stat);
}
+void table_events_waits_summary_by_thread_by_event_name
+::make_socket_row(PFS_thread *thread, PFS_socket_class *klass)
+{
+ PFS_single_stat_chain *stat;
+ stat= find_per_thread_socket_class_wait_stat(thread, klass);
+ make_instr_row(thread, klass, stat);
+}
+
int table_events_waits_summary_by_thread_by_event_name
::read_row_values(TABLE *table, unsigned char *, Field **fields,
bool read_all)
@@ -646,6 +673,24 @@ void table_events_waits_summary_by_insta
*/
make_instr_row(pfs, safe_class, pfs);
}
+
+/**
+ Build a row, for socket statistics in a thread.
+ @param pfs the socket this cursor is reading
+*/
+void table_events_waits_summary_by_instance::make_socket_row(PFS_socket *pfs)
+{
+ PFS_socket_class *safe_class;
+ safe_class= sanitize_socket_class(pfs->m_class);
+ if (unlikely(safe_class == NULL))
+ return;
+
+ /*
+ Files don't have a in memory structure associated to it,
+ so we use the address of the PFS_socket buffer as object_instance_begin
+ */
+ make_instr_row(pfs, safe_class, pfs);
+}
int table_events_waits_summary_by_instance
::read_row_values(TABLE *table, unsigned char *, Field **fields,
=== modified file 'storage/perfschema/table_events_waits_summary.h'
--- a/storage/perfschema/table_events_waits_summary.h 2010-06-03 13:30:54 +0000
+++ b/storage/perfschema/table_events_waits_summary.h 2010-07-07 19:49:15 +0000
@@ -78,7 +78,7 @@ struct pos_events_waits_summary_by_threa
{ return (m_index_1 < thread_max); }
inline bool has_more_view(void)
- { return (m_index_2 <= VIEW_FILE); }
+ { return (m_index_2 <= VIEW_SOCKET); }
inline void next_thread(void)
{
@@ -127,6 +127,7 @@ protected:
void make_rwlock_row(PFS_thread *thread, PFS_rwlock_class *klass);
void make_cond_row(PFS_thread *thread, PFS_cond_class *klass);
void make_file_row(PFS_thread *thread, PFS_file_class *klass);
+ void make_socket_row(PFS_thread *thread, PFS_socket_class *klass);
private:
/** Table share lock. */
@@ -233,6 +234,7 @@ protected:
virtual void make_rwlock_row(PFS_rwlock *pfs);
virtual void make_cond_row(PFS_cond *pfs);
virtual void make_file_row(PFS_file *pfs);
+ virtual void make_socket_row(PFS_socket *pfs);
virtual int read_row_values(TABLE *table,
unsigned char *buf,
=== modified file 'storage/perfschema/table_setup_instruments.cc'
--- a/storage/perfschema/table_setup_instruments.cc 2010-06-03 13:30:54 +0000
+++ b/storage/perfschema/table_setup_instruments.cc 2010-07-07 19:49:15 +0000
@@ -88,6 +88,7 @@ int table_setup_instruments::rnd_next(vo
PFS_rwlock_class *rwlock_class;
PFS_cond_class *cond_class;
PFS_file_class *file_class;
+ PFS_socket_class *socket_class;
for (m_pos.set_at(&m_next_pos);
m_pos.has_more_view();
@@ -133,6 +134,15 @@ int table_setup_instruments::rnd_next(vo
return 0;
}
break;
+ case pos_setup_instruments::VIEW_SOCKET:
+ socket_class= find_socket_class(m_pos.m_index_2);
+ if (socket_class)
+ {
+ make_row(socket_class);
+ m_next_pos.set_after(&m_pos);
+ return 0;
+ }
+ break;
}
}
@@ -145,6 +155,7 @@ int table_setup_instruments::rnd_pos(con
PFS_rwlock_class *rwlock_class;
PFS_cond_class *cond_class;
PFS_file_class *file_class;
+ PFS_socket_class *socket_class;
set_position(pos);
@@ -184,6 +195,14 @@ int table_setup_instruments::rnd_pos(con
return 0;
}
break;
+ case pos_setup_instruments::VIEW_SOCKET:
+ socket_class= find_socket_class(m_pos.m_index_2);
+ if (socket_class)
+ {
+ make_row(socket_class);
+ return 0;
+ }
+ break;
}
return HA_ERR_RECORD_DELETED;
=== modified file 'storage/perfschema/table_setup_instruments.h'
--- a/storage/perfschema/table_setup_instruments.h 2010-06-03 13:30:54 +0000
+++ b/storage/perfschema/table_setup_instruments.h 2010-07-07 19:49:15 +0000
@@ -51,6 +51,7 @@ struct pos_setup_instruments : public PF
/** Reverved for WL#4674, PERFORMANCE_SCHEMA Setup For Actors. */
static const uint VIEW_THREAD= 4;
static const uint VIEW_FILE= 5;
+ static const uint VIEW_SOCKET= 6;
pos_setup_instruments()
: PFS_double_index(VIEW_MUTEX, 1)
=== added file 'storage/perfschema/table_socket_instances.cc'
--- a/storage/perfschema/table_socket_instances.cc 1970-01-01 00:00:00 +0000
+++ b/storage/perfschema/table_socket_instances.cc 2010-07-07 19:49:15 +0000
@@ -0,0 +1,189 @@
+/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+
+ 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; version 2 of the License.
+
+ 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,
+ 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+/**
+ @file storage/perfschema/table_socket_instances.cc
+ Table SOCKET_INSTANCES (implementation).
+*/
+
+#include "my_global.h"
+#include "my_pthread.h"
+#include "pfs_instr.h"
+#include "pfs_column_types.h"
+#include "pfs_column_values.h"
+#include "table_socket_instances.h"
+#include "pfs_global.h"
+
+THR_LOCK table_socket_instances::m_table_lock;
+
+static const TABLE_FIELD_TYPE field_types[]=
+{
+ {
+ { C_STRING_WITH_LEN("SOCKET_DESC") },
+ { C_STRING_WITH_LEN("varchar(512)") },
+ { NULL, 0}
+ },
+ {
+ { C_STRING_WITH_LEN("EVENT_NAME") },
+ { C_STRING_WITH_LEN("varchar(128)") },
+ { NULL, 0}
+ },
+ {
+ { C_STRING_WITH_LEN("IDENTITY") }, // TBD
+ { C_STRING_WITH_LEN("bigint(20)") },
+ { NULL, 0}
+ },
+ {
+ { C_STRING_WITH_LEN("OPEN_COUNT") },
+ { C_STRING_WITH_LEN("int(10)") },
+ { NULL, 0}
+ }
+};
+
+TABLE_FIELD_DEF
+table_socket_instances::m_field_def=
+{ 4, field_types };
+
+PFS_engine_table_share
+table_socket_instances::m_share=
+{
+ { C_STRING_WITH_LEN("SOCKET_INSTANCES") },
+ &pfs_readonly_acl,
+ &table_socket_instances::create,
+ NULL, /* write_row */
+ NULL, /* delete_all_rows */
+ 1000, /* records */
+ sizeof(PFS_simple_index),
+ &m_table_lock,
+ &m_field_def,
+ false /* checked */
+};
+
+PFS_engine_table* table_socket_instances::create(void)
+{
+ return new table_socket_instances();
+}
+
+table_socket_instances::table_socket_instances()
+ : PFS_engine_table(&m_share, &m_pos),
+ m_row_exists(false), m_pos(0), m_next_pos(0)
+{}
+
+void table_socket_instances::reset_position(void)
+{
+ m_pos.m_index= 0;
+ m_next_pos.m_index= 0;
+}
+
+int table_socket_instances::rnd_next(void)
+{
+ PFS_socket *pfs;
+
+ for (m_pos.set_at(&m_next_pos);
+ m_pos.m_index < socket_max;
+ m_pos.next())
+ {
+ pfs= &socket_array[m_pos.m_index];
+ if (pfs->m_lock.is_populated())
+ {
+ make_row(pfs);
+ m_next_pos.set_after(&m_pos);
+ return 0;
+ }
+ }
+
+ return HA_ERR_END_OF_FILE;
+}
+
+int table_socket_instances::rnd_pos(const void *pos)
+{
+ PFS_socket *pfs;
+
+ set_position(pos);
+ DBUG_ASSERT(m_pos.m_index < socket_max);
+ pfs= &socket_array[m_pos.m_index];
+
+ if (! pfs->m_lock.is_populated())
+ return HA_ERR_RECORD_DELETED;
+
+ make_row(pfs);
+ return 0;
+}
+
+void table_socket_instances::make_row(PFS_socket *pfs)
+{
+ pfs_lock lock;
+ PFS_socket_class *safe_class;
+
+ m_row_exists= false;
+
+ /* Protect this reader against a socket delete */
+ pfs->m_lock.begin_optimistic_lock(&lock);
+
+ safe_class= sanitize_socket_class(pfs->m_class);
+ if (unlikely(safe_class == NULL))
+ return;
+
+ m_row.m_socket_desc= pfs->m_socket_desc;
+ m_row.m_socket_desc_length= pfs->m_socket_desc_length;
+ m_row.m_event_name= safe_class->m_name;
+ m_row.m_event_name_length= safe_class->m_name_length;
+ m_row.m_identity= pfs->m_identity;
+ m_row.m_open_count= pfs->m_socket_stat.m_open_count;
+
+ if (pfs->m_lock.end_optimistic_lock(&lock))
+ m_row_exists= true;
+}
+
+int table_socket_instances::read_row_values(TABLE *table,
+ unsigned char *,
+ Field **fields,
+ bool read_all)
+{
+ Field *f;
+
+ if (unlikely(! m_row_exists))
+ return HA_ERR_RECORD_DELETED;
+
+ /* Set the null bits */
+ DBUG_ASSERT(table->s->null_bytes == 0);
+
+ for (; (f= *fields) ; fields++)
+ {
+ if (read_all || bitmap_is_set(table->read_set, f->field_index))
+ {
+ switch(f->field_index)
+ {
+ case 0: /* SOCKET_DESC */
+ set_field_varchar_utf8(f, m_row.m_socket_desc, m_row.m_socket_desc_length);
+ break;
+ case 1: /* EVENT_NAME */
+ set_field_varchar_utf8(f, m_row.m_event_name, m_row.m_event_name_length);
+ break;
+ case 2: /* IDENTITY */
+ set_field_ulonglong(f, (intptr)m_row.m_identity);
+ break;
+ case 3: /* OPEN_COUNT */
+ set_field_ulong(f, m_row.m_open_count);
+ break;
+ default:
+ DBUG_ASSERT(false);
+ }
+ }
+ }
+
+ return 0;
+}
+
=== added file 'storage/perfschema/table_socket_instances.h'
--- a/storage/perfschema/table_socket_instances.h 1970-01-01 00:00:00 +0000
+++ b/storage/perfschema/table_socket_instances.h 2010-07-07 19:49:15 +0000
@@ -0,0 +1,92 @@
+/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+
+ 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; version 2 of the License.
+
+ 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,
+ 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+#ifndef TABLE_SOCKET_INSTANCES_H
+#define TABLE_SOCKET_INSTANCES_H
+
+/**
+ @file storage/perfschema/table_socket_instances.h
+ Table SOCKET_INSTANCES (declarations).
+*/
+
+#include "pfs_column_types.h"
+#include "pfs_engine_table.h"
+
+/**
+ @addtogroup Performance_schema_tables
+ @{
+*/
+
+/** A row of PERFORMANCE_SCHEMA.SOCKET_INSTANCES. */
+struct row_socket_instances
+{
+ /** Column SOCKET_DESC. */
+ const char *m_socket_desc;
+ /** Length in bytes of @c m_socket_desc. */
+ uint m_socket_desc_length;
+ /** Column EVENT_NAME. */
+ const char *m_event_name;
+ /** Length in bytes of @c m_event_name. */
+ uint m_event_name_length;
+ /** IDENTITY TBD */
+ const void *m_identity;
+ /** Column OPEN_COUNT. */
+ uint m_open_count;
+};
+
+/** Table PERFORMANCE_SCHEMA.SOCKET_INSTANCES. */
+class table_socket_instances : public PFS_engine_table
+{
+public:
+ /** Table share */
+ static PFS_engine_table_share m_share;
+ static PFS_engine_table* create();
+
+ virtual int rnd_next();
+ virtual int rnd_pos(const void *pos);
+ virtual void reset_position(void);
+
+private:
+ virtual int read_row_values(TABLE *table,
+ unsigned char *buf,
+ Field **fields,
+ bool read_all);
+
+ table_socket_instances();
+
+public:
+ ~table_socket_instances()
+ {}
+
+private:
+ void make_row(PFS_socket *pfs);
+
+ /** Table share lock. */
+ static THR_LOCK m_table_lock;
+ /** Fields definition. */
+ static TABLE_FIELD_DEF m_field_def;
+
+ /** Current row. */
+ row_socket_instances m_row;
+ /** True is the current row exists. */
+ bool m_row_exists;
+ /** Current position. */
+ PFS_simple_index m_pos;
+ /** Next position. */
+ PFS_simple_index m_next_pos;
+};
+
+/** @} */
+#endif
Attachment: [text/bzr-bundle] bzr/chris.powers@oracle.com-20100707194915-tib7g12cnjlcge8e.bundle
| Thread |
|---|
| • bzr commit into mysql-next-mr-wl4896 branch (chris.powers:3152) WL#4896 | Christopher Powers | 7 Jul |