3254 cpowers 2011-03-11
WL#4896 "Performance Schema Net IO"
- Added get_thread_id API
- Set corresponding thread_id during socket create
modified:
include/mysql/psi/mysql_socket.h
include/mysql/psi/psi.h
storage/perfschema/pfs.cc
3253 cpowers 2011-03-11
WL#4896 "Performance Schema Net IO"
Resolved test failures caused when performance_schema_max_sockets was
renamed to performance_schema_max_socket_instances:
- Renamed sys_vars.pfs_max_socket to sys_vars.pfs_max_socket_instances
- Re-record mysqld--help-win.result
renamed:
mysql-test/suite/sys_vars/r/pfs_max_sockets_basic.result => mysql-test/suite/sys_vars/r/pfs_max_socket_instances_basic.result
mysql-test/suite/sys_vars/t/pfs_max_sockets_basic-master.opt => mysql-test/suite/sys_vars/t/pfs_max_socket_instances_basic-master.opt
mysql-test/suite/sys_vars/t/pfs_max_sockets_basic.test => mysql-test/suite/sys_vars/t/pfs_max_socket_instances_basic.test
modified:
mysql-test/r/mysqld--help-win.result
mysql-test/suite/sys_vars/r/all_vars.result
=== modified file 'include/mysql/psi/mysql_socket.h'
--- a/include/mysql/psi/mysql_socket.h 2011-03-10 17:56:04 +0000
+++ b/include/mysql/psi/mysql_socket.h 2011-03-12 00:00:13 +0000
@@ -400,12 +400,22 @@ inline_mysql_socket_socket
int domain, int type, int protocol)
{
MYSQL_SOCKET mysql_socket;
+ ulong thread_id;
mysql_socket.fd= socket(domain, type, protocol);
#ifdef HAVE_PSI_INTERFACE
mysql_socket.m_psi = PSI_server ? PSI_server->init_socket(key, &mysql_socket.fd)
: NULL;
+
+ if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL
+ && mysql_socket.fd != -1))
+ {
+ thread_id= PSI_server->get_thread_id();
+ PSI_server->set_socket_info(mysql_socket.m_psi, &mysql_socket.fd,
+ NULL, 0, thread_id);
+ }
+
#endif
return mysql_socket;
}
@@ -789,7 +799,8 @@ inline_mysql_socket_accept
#endif
MYSQL_SOCKET socket_listen, struct sockaddr *addr, socklen_t *addr_len)
{
- MYSQL_SOCKET socket_accept = {0, NULL};
+ MYSQL_SOCKET socket_accept = MYSQL_INVALID_SOCKET;
+ ulong thread_id;
socket_accept.fd= accept(socket_listen.fd, addr, addr_len);
@@ -800,8 +811,11 @@ inline_mysql_socket_accept
if (likely(PSI_server != NULL && socket_accept.m_psi != NULL
&& socket_accept.fd != -1))
- PSI_server->set_socket_info(socket_accept.m_psi, &socket_accept.fd,
- addr, addr_len);
+ {
+ thread_id= PSI_server->get_thread_id();
+ PSI_server->set_socket_info(socket_accept.m_psi, &socket_accept.fd,
+ addr, addr_len, thread_id);
+ }
#endif
return socket_accept;
}
=== modified file 'include/mysql/psi/psi.h'
--- a/include/mysql/psi/psi.h 2011-03-09 23:28:32 +0000
+++ b/include/mysql/psi/psi.h 2011-03-12 00:00:13 +0000
@@ -928,6 +928,15 @@ typedef void (*set_thread_id_v1_t)(struc
typedef struct PSI_thread* (*get_thread_v1_t)(void);
/**
+ Get the thread id of the running thread.
+ For this function to return a result,
+ the thread instrumentation must have been attached to the
+ running thread using @c set_thread()
+ @return the thread id of the running thread
+*/
+typedef ulong (*get_thread_id_v1_t)(void);
+
+/**
Assign a user name to the instrumented thread.
@param user the user name
@param user_len the user name length
@@ -1319,11 +1328,13 @@ typedef void (*set_socket_address_v1_t)(
@param fd the socket descriptor
@param addr the socket ip address
@param addr_len length of socket ip address
+ @param thread_id associated thread id
*/
typedef void (*set_socket_info_v1_t)(struct PSI_socket *socket,
my_socket *fd,
const struct sockaddr *addr,
- socklen_t *addr_len);
+ socklen_t *addr_len,
+ ulong thread_id);
/**
Performance Schema Interface, version 1.
@@ -1379,6 +1390,8 @@ struct PSI_v1
set_thread_id_v1_t set_thread_id;
/** @sa get_thread_v1_t. */
get_thread_v1_t get_thread;
+ /** @sa get_thread_id_v1_t. */
+ get_thread_id_v1_t get_thread_id;
/** @sa set_thread_user_v1_t. */
set_thread_user_v1_t set_thread_user;
/** @sa set_thread_user_host_v1_t. */
=== modified file 'storage/perfschema/pfs.cc'
--- a/storage/perfschema/pfs.cc 2011-03-09 23:28:32 +0000
+++ b/storage/perfschema/pfs.cc 2011-03-12 00:00:13 +0000
@@ -1554,6 +1554,17 @@ get_thread_v1(void)
/**
Implementation of the thread instrumentation interface.
+ @sa PSI_v1::get_thread.
+*/
+static ulong
+get_thread_id_v1(void)
+{
+ PFS_thread *pfs= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
+ return (likely(pfs != NULL) ? pfs->m_thread_id : 0);
+}
+
+/**
+ Implementation of the thread instrumentation interface.
@sa PSI_v1::set_thread_user.
*/
static void set_thread_user_v1(const char *user, int user_len)
@@ -3805,7 +3816,8 @@ static void set_socket_address_v1(PSI_so
static void set_socket_info_v1(PSI_socket *socket,
my_socket *fd,
const struct sockaddr *addr,
- socklen_t *addr_len)
+ socklen_t *addr_len,
+ ulong thread_id)
{
DBUG_ASSERT(socket);
PFS_socket *pfs= reinterpret_cast<PFS_socket*>(socket);
@@ -3826,6 +3838,9 @@ static void set_socket_info_v1(PSI_socke
if (likely(pfs->m_sock_len > 0))
memcpy(&pfs->m_sock_addr, addr, pfs->m_sock_len);
}
+
+ /** Set thread id associated with this socket */
+ pfs->m_thread_id= thread_id;
}
/**
@@ -3858,6 +3873,7 @@ PSI_v1 PFS_v1=
new_thread_v1,
set_thread_id_v1,
get_thread_v1,
+ get_thread_id_v1,
set_thread_user_v1,
set_thread_user_host_v1,
set_thread_db_v1,
Attachment: [text/bzr-bundle] bzr/cpowers@tma-1-20110312000013-bj8sh7ifftb6awxh.bundle
| Thread |
|---|
| • bzr push into mysql-trunk branch (chris.powers:3253 to 3254) WL#4896 | Christopher Powers | 12 Mar |