List:Commits« Previous MessageNext Message »
From:Christopher Powers Date:June 7 2010 9:03pm
Subject:bzr push into mysql-next-mr-wl4896 branch (chris.powers:3146 to 3147) WL#4896
View as plain text  
 3147 Christopher Powers	2010-06-07
      WL#4896 PERFORMANCE_SCHEMA Instrumenting Net IO
      
      Socket API wrappers, intermediate version

    added:
      include/mysql/psi/mysql_socket.h
    modified:
      include/mysql/psi/psi.h
 3146 Christopher Powers	2010-06-03 [merge]
      local merge

    added:
      mysql-test/extra/rpl_tests/rpl_record_compare.test
      mysql-test/include/mysqlbinlog_raw_mode.inc
      mysql-test/r/bug46261.result
      mysql-test/r/mysqlbinlog_raw_mode.result
      mysql-test/r/mysqlbinlog_raw_mode_win.result
      mysql-test/std_data/binlog_savepoint.000001
      mysql-test/std_data/bug46565.ARZ
      mysql-test/std_data/bug46565.frm
      mysql-test/suite/parts/r/partition_debug_sync_innodb.result
      mysql-test/suite/parts/t/partition_debug_sync_innodb-master.opt
      mysql-test/suite/parts/t/partition_debug_sync_innodb.test
      mysql-test/suite/rpl/r/rpl_row_rec_comp_innodb.result
      mysql-test/suite/rpl/r/rpl_row_rec_comp_myisam.result
      mysql-test/suite/rpl/t/rpl_begin_commit_rollback-master.opt
      mysql-test/suite/rpl/t/rpl_row_rec_comp_innodb.test
      mysql-test/suite/rpl/t/rpl_row_rec_comp_myisam.test
      mysql-test/suite/sys_vars/r/secure_file_priv.result
      mysql-test/suite/sys_vars/r/skip_name_resolve_basic.result
      mysql-test/suite/sys_vars/t/secure_file_priv-master.opt
      mysql-test/suite/sys_vars/t/secure_file_priv.test
      mysql-test/suite/sys_vars/t/skip_name_resolve_basic-master.opt
      mysql-test/suite/sys_vars/t/skip_name_resolve_basic.test
      mysql-test/t/bug46261-master.opt
      mysql-test/t/bug46261.test
      mysql-test/t/mysqlbinlog_raw_mode.test
      mysql-test/t/mysqlbinlog_raw_mode_win.test
    modified:
      Makefile.am
      client/Makefile.am
      client/client_priv.h
      client/mysqlbinlog.cc
      configure.in
      include/my_global.h
      include/mysql/plugin.h
      include/mysql/plugin.h.pp
      include/mysql_com.h
      mysql-test/extra/binlog_tests/mix_innodb_myisam_side_effects.test
      mysql-test/mysql-test-run.pl
      mysql-test/r/archive.result
      mysql-test/r/ctype_ucs.result
      mysql-test/r/delete.result
      mysql-test/r/error_simulation.result
      mysql-test/r/explain.result
      mysql-test/r/fulltext.result
      mysql-test/r/func_concat.result
      mysql-test/r/func_gconcat.result
      mysql-test/r/func_str.result
      mysql-test/r/gis-rtree.result
      mysql-test/r/grant.result
      mysql-test/r/group_by.result
      mysql-test/r/handler_myisam.result
      mysql-test/r/having.result
      mysql-test/r/innodb_mysql.result
      mysql-test/r/join.result
      mysql-test/r/join_outer.result
      mysql-test/r/loaddata.result
      mysql-test/r/log_state.result
      mysql-test/r/myisam.result
      mysql-test/r/mysqlbinlog.result
      mysql-test/r/mysqld--help-notwin.result
      mysql-test/r/mysqld--help-win.result
      mysql-test/r/mysqldump.result
      mysql-test/r/outfile_loaddata.result
      mysql-test/r/partition.result
      mysql-test/r/ps.result
      mysql-test/r/query_cache_with_views.result
      mysql-test/r/range.result
      mysql-test/r/renamedb.result
      mysql-test/r/row.result
      mysql-test/r/skip_name_resolve.result
      mysql-test/r/subselect.result
      mysql-test/r/symlink.result
      mysql-test/r/trigger.result
      mysql-test/r/upgrade.result
      mysql-test/r/variables.result
      mysql-test/r/variables_debug.result
      mysql-test/r/view.result
      mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result
      mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result
      mysql-test/suite/engines/README
      mysql-test/suite/engines/iuds/r/update_delete_calendar.result
      mysql-test/suite/engines/iuds/t/disabled.def
      mysql-test/suite/engines/iuds/t/insert_number.test
      mysql-test/suite/engines/iuds/t/update_delete_calendar.test
      mysql-test/suite/rpl/r/rpl_begin_commit_rollback.result
      mysql-test/suite/rpl/r/rpl_do_grant.result
      mysql-test/suite/rpl/r/rpl_events.result
      mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result
      mysql-test/suite/rpl/r/rpl_mixed_mixing_engines.result
      mysql-test/suite/rpl/r/rpl_non_direct_mixed_mixing_engines.result
      mysql-test/suite/rpl/r/rpl_non_direct_row_mixing_engines.result
      mysql-test/suite/rpl/r/rpl_non_direct_stm_mixing_engines.result
      mysql-test/suite/rpl/r/rpl_row_mixing_engines.result
      mysql-test/suite/rpl/r/rpl_stm_mixing_engines.result
      mysql-test/suite/rpl/t/rpl_begin_commit_rollback.test
      mysql-test/suite/rpl/t/rpl_do_grant.test
      mysql-test/suite/rpl/t/rpl_events.test
      mysql-test/suite/rpl/t/rpl_stm_mixing_engines.test
      mysql-test/suite/rpl_ndb/my.cnf
      mysql-test/suite/rpl_ndb/r/rpl_ndb_stm_innodb.result
      mysql-test/suite/rpl_ndb/t/rpl_ndb_stm_innodb.test
      mysql-test/suite/sys_vars/r/myisam_sort_buffer_size_basic_32.result
      mysql-test/suite/sys_vars/r/myisam_sort_buffer_size_basic_64.result
      mysql-test/suite/sys_vars/t/secure_file_priv_basic.test
      mysql-test/t/archive.test
      mysql-test/t/ctype_ucs.test
      mysql-test/t/delete.test
      mysql-test/t/error_simulation.test
      mysql-test/t/explain.test
      mysql-test/t/fulltext.test
      mysql-test/t/func_concat.test
      mysql-test/t/func_gconcat.test
      mysql-test/t/func_str.test
      mysql-test/t/gis-rtree.test
      mysql-test/t/grant.test
      mysql-test/t/group_by.test
      mysql-test/t/handler_myisam.test
      mysql-test/t/having.test
      mysql-test/t/innodb_mysql.test
      mysql-test/t/join.test
      mysql-test/t/join_outer.test
      mysql-test/t/loaddata.test
      mysql-test/t/log_state.test
      mysql-test/t/mysqlbinlog.test
      mysql-test/t/mysqldump.test
      mysql-test/t/outfile_loaddata.test
      mysql-test/t/partition.test
      mysql-test/t/ps.test
      mysql-test/t/query_cache_with_views.test
      mysql-test/t/range.test
      mysql-test/t/renamedb.test
      mysql-test/t/row.test
      mysql-test/t/skip_name_resolve.test
      mysql-test/t/subselect.test
      mysql-test/t/symlink.test
      mysql-test/t/trigger.test
      mysql-test/t/upgrade.test
      mysql-test/t/variables.test
      mysql-test/t/variables_debug.test
      mysql-test/t/view.test
      mysys/mf_loadpath.c
      mysys/mf_pack.c
      mysys/my_file.c
      mysys/my_getwd.c
      scripts/mysqld_safe.sh
      scripts/mysqlhotcopy.sh
      sql-common/client.c
      sql/CMakeLists.txt
      sql/authors.h
      sql/events.cc
      sql/field.cc
      sql/field.h
      sql/field_conv.cc
      sql/ha_partition.cc
      sql/handler.cc
      sql/handler.h
      sql/item.cc
      sql/item.h
      sql/item_cmpfunc.h
      sql/item_strfunc.cc
      sql/item_strfunc.h
      sql/item_subselect.cc
      sql/item_subselect.h
      sql/item_sum.cc
      sql/log.cc
      sql/log.h
      sql/log_event.cc
      sql/log_event.h
      sql/log_event_old.cc
      sql/mysqld.cc
      sql/mysqld.h
      sql/net_serv.cc
      sql/opt_range.cc
      sql/opt_range.h
      sql/opt_sum.cc
      sql/partition_info.cc
      sql/protocol.cc
      sql/slave.cc
      sql/sp_head.cc
      sql/sp_head.h
      sql/sql_acl.cc
      sql/sql_base.cc
      sql/sql_base.h
      sql/sql_class.cc
      sql/sql_class.h
      sql/sql_connect.cc
      sql/sql_delete.cc
      sql/sql_insert.cc
      sql/sql_lex.cc
      sql/sql_lex.h
      sql/sql_load.cc
      sql/sql_parse.cc
      sql/sql_partition.cc
      sql/sql_plugin.cc
      sql/sql_repl.cc
      sql/sql_select.cc
      sql/sql_show.cc
      sql/sql_table.cc
      sql/sql_table.h
      sql/sql_update.cc
      sql/sql_yacc.yy
      sql/sys_vars.cc
      sql/table.cc
      sql/table.h
      storage/archive/ha_archive.cc
      storage/myisam/ha_myisam.cc
      storage/myisam/mi_check.c
      storage/myisam/mi_delete_all.c
      storage/myisam/mi_delete_table.c
      storage/myisam/mi_dynrec.c
      storage/myisam/mi_extra.c
      storage/myisam/mi_open.c
      storage/myisam/mi_page.c
      storage/myisam/mi_rnext.c
      storage/myisam/mi_write.c
      storage/myisam/myisamdef.h
      storage/myisam/rt_index.c
      storage/myisam/rt_split.c
      storage/myisam/sort.c
      tests/mysql_client_test.c
=== added file 'include/mysql/psi/mysql_socket.h'
--- a/include/mysql/psi/mysql_socket.h	1970-01-01 00:00:00 +0000
+++ b/include/mysql/psi/mysql_socket.h	2010-06-07 21:03:19 +0000
@@ -0,0 +1,838 @@
+/* Copyright (c) 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, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+02110-1301  USA
+*/
+
+#ifndef MYSQL_SOCKET_H
+#define MYSQL_SOCKET_H
+
+/* For strlen() */
+#include <string.h>
+/* For MY_STAT */
+#include <my_dir.h>
+/* For my_chsize */
+#include <my_sys.h>
+
+/**
+  @file mysql/psi/mysql_socket.h
+[...]
+*/
+
+#include "mysql/psi/psi.h"
+
+/**
+  @defgroup Network_instrumentation Network Instrumentation
+  @ingroup Instrumentation_interface
+  @{
+*/
+
+#ifdef HAVE_PSI_INTERFACE
+  #define mysql_socket_socket(D, T, P) \
+    inline mysql_socket_socket(__FILE__, __LINE__, D, T, P)
+#else
+  #define mysql_socket_socket(D, T, P) \
+    inline_mysql_socket_socket(D, T, P)
+#endif
+		
+#ifdef HAVE_PSI_INTERFACE
+  #define mysql_socket_socketpair(D, T, P, SDS) \
+    inline mysql_socket_socketpair(__FILE__, __LINE__, D, T, P, SDS)
+#else
+  #define mysql_socket_socketpair(D, T, P, SDS) \
+    inline_mysql_socket_socketpair(D, T, P, SDS)
+#endif
+		
+#ifdef HAVE_PSI_INTERFACE
+  #define mysql_socket_bind(SD, A, L) \
+    inline mysql_socket_bind(__FILE__, __LINE__, SD, A, L)
+#else
+  #define mysql_socket_bind(SD, A, L) \
+    inline_mysql_socket_bind(SD, A, L)
+#endif
+		
+#ifdef HAVE_PSI_INTERFACE
+  #define mysql_socket_getsockname(SD, A, LP) \
+    inline mysql_socket_getsockname(__FILE__, __LINE__, SD, A, LP)
+#else
+  #define mysql_socket_getsockname(SD, A, LP) \
+    inline_mysql_socket_getsockname(SD, A, LP)
+#endif
+		
+#ifdef HAVE_PSI_INTERFACE
+  #define mysql_socket_connect(SD, A, L) \
+    inline mysql_socket_connect(__FILE__, __LINE__, SD, A, L)
+#else
+  #define mysql_socket_connect(SD, A, L) \
+    inline_mysql_socket_connect(SD, A, L)
+#endif
+		
+#ifdef HAVE_PSI_INTERFACE
+  #define mysql_socket_getpeername(SD, A, LP) \
+    inline mysql_socket_getpeername(__FILE__, __LINE__, SD, A, LP)
+#else
+  #define mysql_socket_getpeername(SD, A, LP) \
+    inline_mysql_socket_getpeername(SD, 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)
+#else
+  #define mysql_socket_send(SD, B, N, FL) \
+    inline_mysql_socket_send(SD, 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)
+#else
+  #define mysql_socket_recv(SD, B, N, FL) \
+    inline_mysql_socket_recv(SD, 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)
+#else
+  #define mysql_socket_sendto(SD, B, N, FL, A, L) \
+    inline_mysql_socket_sendto(SD, 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)
+#else
+  #define mysql_socket_recvfrom(SD, B, N, FL, A, LP) \
+    inline_mysql_socket_recvfrom(SD, 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)
+#else
+  #define mysql_socket_sendmsg(SD, M, FL) \
+    inline_mysql_socket_sendmsg(SD, M, FL)
+#endif
+		
+#ifdef HAVE_PSI_INTERFACE
+  #define mysql_socket_recvmsg(SD, M, FL) \
+    inline mysql_socket_recvmsg(__FILE__, __LINE__, SD, M, FL)
+#else
+  #define mysql_socket_recvmsg(SD, M, FL) \
+    inline_mysql_socket_recvmsg(SD, 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)
+#else
+  #define mysql_socket_getsockopt(SD, LV, ON, OP, OL) \
+    inline_mysql_socket_getsockopt(SD, 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)
+#else
+  #define mysql_socket_setsockopt(SD, LV, ON, OP, OL) \
+    inline_mysql_socket_setsockopt(SD, LV, ON, OP, OL)
+#endif
+		
+#ifdef HAVE_PSI_INTERFACE
+  #define mysql_socket_listen(SD, N) \
+    inline mysql_socket_listen(__FILE__, __LINE__, SD, N)
+#else
+  #define mysql_socket_listen(SD, N) \
+    inline_mysql_socket_listen(SD, N)
+#endif
+		
+#ifdef HAVE_PSI_INTERFACE
+  #define mysql_socket_accept(SD, A, LP) \
+    inline mysql_socket_accept(__FILE__, __LINE__, SD, A, LP)
+#else
+  #define mysql_socket_accept(SD, A, LP) \
+    inline_mysql_socket_accept(SD, A, LP)
+#endif
+		
+#ifdef HAVE_PSI_INTERFACE
+  #define mysql_socket_accept4(SD, A, LP, FL) \
+    inline mysql_socket_accept4(__FILE__, __LINE__, SD, A, LP, FL)
+#else
+  #define mysql_socket_accept4(SD, A, LP, FL) \
+    inline_mysql_socket_accept4(SD, A, LP, FL)
+#endif
+		
+#ifdef HAVE_PSI_INTERFACE
+  #define mysql_socket_shutdown(SD, H) \
+    inline mysql_socket_shutdown(__FILE__, __LINE__, SD, H)
+#else
+  #define mysql_socket_shutdown(SD, H) \
+    inline_mysql_socket_shutdown(SD, H)
+#endif
+		
+#ifdef HAVE_PSI_INTERFACE
+  #define mysql_socket_sockatmark(SD) \
+    inline mysql_socket_sockatmark(__FILE__, __LINE__, SD)
+#else
+  #define mysql_socket_sockatmark(SD) \
+    inline_mysql_socket_sockatmark(SD)
+#endif
+		
+#ifdef HAVE_PSI_INTERFACE
+  #define mysql_socket_isfdtype(SD, FT) \
+    inline mysql_socket_isfdtype(__FILE__, __LINE__, SD, FT)
+#else
+  #define mysql_socket_isfdtype(SD, FT) \
+    inline_mysql_socket_isfdtype(SD, FT)
+#endif
+		
+
+
+
+
+int mysql_socket_socket(D, T, P)
+int mysql_socket_socketpair(D, T, P, SDS)
+int mysql_socket_bind(SD, A, L)
+int mysql_socket_getsockname(SD, A, LP)
+int mysql_socket_connect(SD, A, L)
+int mysql_socket_getpeername(SD, A, LP)
+ssize_t mysql_socket_send(SD, B, N, FL)
+ssize_t mysql_socket_recv(SD, B, N, FL)
+ssize_t mysql_socket_sendto(SD, B, N, FL, A, L)
+ssize_t mysql_socket_recvfrom(SD, B, N, FL, A, LP)
+ssize_t mysql_socket_sendmsg(SD, M, FL)
+ssize_t mysql_socket_recvmsg(SD, M, FL)
+int mysql_socket_getsockopt(SD, LV, ON, OP, OL)
+int mysql_socket_setsockopt(SD, LV, ON, OP, OL)
+int mysql_socket_listen(SD, N)
+int mysql_socket_accept(SD, A, LP)
+int mysql_socket_accept4(SD, A, LP, FL)
+int mysql_socket_shutdown(SD, H)
+int mysql_socket_sockatmark(SD)
+int mysql_socket_isfdtype(SD, FT)
+
+
+
+int socket (int domain, int type, int protocol);
+int socketpair (int domain, int type, int protocol, int fds[2]);
+int bind (int fd, CONST_SOCKADDR_ARG addr, socklen_t len);
+int getsockname (int fd, SOCKADDR_ARG addr, socklen_t *restrict len);
+int connect (int fd, CONST_SOCKADDR_ARG addr, socklen_t len);
+int getpeername (int fd, SOCKADDR_ARG addr, socklen_t *restrict len);
+ssize_t send (int fd, const void *buf, size_t n, int flags);
+ssize_t recv (int fd, void *buf, size_t n, int flags);
+ssize_t sendto (int fd, const void *buf, size_t n, int flags, CONST_SOCKADDR_ARG addr, socklen_t addr_len);
+ssize_t recvfrom (int fd, void *restrict buf, size_t n, int flags, SOCKADDR_ARG addr, socklen_t *restrict addr_len);
+ssize_t sendmsg (int fd, const struct msghdr *message, int flags);
+ssize_t recvmsg (int fd, struct msghdr *message, int flags);
+int getsockopt (int fd, int level, int optname, void *restrict optval, socklen_t *restrict optlen);
+int setsockopt (int fd, int level, int optname, const void *optval, socklen_t optlen);
+int listen (int fd, int n);
+int accept (int fd, SOCKADDR_ARG addr, socklen_t *restrict addr_len);
+int accept4 (int fd, SOCKADDR_ARG addr, socklen_t *restrict addr_len, int flags);
+int shutdown (int fd, int how);
+int sockatmark (int fd);
+int isfdtype (int fd, int fdtype);
+
+
+struct st_mysql_socket
+{
+  /** The real socket identifier. */
+  my_socket sd;
+  /**
+    The instrumentation hook.
+    Note that this hook is not conditionally defined,
+    for binary compatibility of the @c MYSQL_FILE interface.
+  */
+
+  struct PSI_socket *m_psi;
+};
+
+/**
+  Type of an instrumented socket.
+  @c MYSQL_SOCKET is a replacement for @c my_socket.
+  @sa mysql_file_open
+*/
+
+typedef struct st_mysql_socket_t MYSQL_SOCKET;
+
+
+/** mysql_socket_socket */
+
+static inline int
+inline_mysql_socket_socket
+(
+#ifdef HAVE_PSI_INTERFACE
+  const char *src_file, uint src_line,
+#endif
+  int domain, int type, int protocol)
+{
+  int result;
+#ifdef HAVE_PSI_INTERFACE
+  struct PSI_socket_locker *locker= NULL;
+  if (likely(PSI_server != NULL))
+  {
+    locker= PSI_server->get_thread_socket_locker(sd->m_psi, PSI_SOCKET_CREATE);
+	if (likely(locker !=NULL))
+	  PSI_server->start_socket_wait(locker, src_file, src_line);
+  }
+#endif
+  result= socket(int domain, int type, int protocol);
+#ifdef HAVE_PSI_INTERFACE
+  if (likely(locker != NULL))
+    PSI_server->end_socket_wait(locker, socket);
+#endif
+  return result;
+}
+
+/** mysql_socket_socketpair */
+
+static inline int
+inline_mysql_socket_socketpair
+(
+#ifdef HAVE_PSI_INTERFACE
+  const char *src_file, uint src_line,
+#endif
+  int domain, int type, int protocol, int fds[2])
+{
+  int result;
+#ifdef HAVE_PSI_INTERFACE
+  struct PSI_socket_locker *locker= NULL;
+  if (likely(PSI_server != NULL))
+  {
+    locker= PSI_server->get_thread_socket_locker(sd->m_psi, PSI_SOCKET_CREATE);
+	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]);
+#ifdef HAVE_PSI_INTERFACE
+  if (likely(locker != NULL))
+    PSI_server->end_socket_wait(locker, socket);
+#endif
+  return result;
+}
+
+/** mysql_socket_bind */
+
+static inline int
+inline_mysql_socket_bind
+(
+#ifdef HAVE_PSI_INTERFACE
+  const char *src_file, uint src_line,
+#endif
+  MYSQL_SOCKET *sd, CONST_SOCKADDR_ARG addr, socklen_t len)
+{
+  int result;
+#ifdef HAVE_PSI_INTERFACE
+  struct PSI_socket_locker *locker= NULL;
+  if (likely(PSI_server != NULL))
+  {
+    locker= PSI_server->get_thread_socket_locker(sd->m_psi, PSI_SOCKET_BIND);
+	if (likely(locker !=NULL))
+	  PSI_server->start_socket_wait(locker, src_file, src_line);
+  }
+#endif
+  result= bind(sd->sd, addr, len);
+#ifdef HAVE_PSI_INTERFACE
+  if (likely(locker != NULL))
+    PSI_server->end_socket_wait(locker, socket);
+#endif
+  return result;
+}
+
+/** mysql_socket_getsockname */
+
+static inline int
+inline_mysql_socket_getsockname
+(
+#ifdef HAVE_PSI_INTERFACE
+  const char *src_file, uint src_line,
+#endif
+ MYSQL_SOCKET *sd, SOCKADDR_ARG addr, socklen_t *restrict len)
+{
+  int result;
+#ifdef HAVE_PSI_INTERFACE
+  struct PSI_socket_locker *locker= NULL;
+  if (likely(PSI_server != NULL))
+  {
+    locker= PSI_server->get_thread_socket_locker(sd->m_psi, PSI_SOCKET_BIND);
+	if (likely(locker !=NULL))
+	  PSI_server->start_socket_wait(locker, src_file, src_line);
+  }
+#endif
+  result= getsockname(sd->sd, addr, *restrict len);
+#ifdef HAVE_PSI_INTERFACE
+  if (likely(locker != NULL))
+    PSI_server->end_socket_wait(locker, socket);
+#endif
+  return result;
+}
+
+/** mysql_socket_connect */
+
+static inline int
+inline_mysql_socket_connect
+(
+#ifdef HAVE_PSI_INTERFACE
+  const char *src_file, uint src_line,
+#endif
+ MYSQL_SOCKET *sd,  CONST_SOCKADDR_ARG addr, socklen_t len)
+{
+  int result;
+#ifdef HAVE_PSI_INTERFACE
+  struct PSI_socket_locker *locker= NULL;
+  if (likely(PSI_server != NULL))
+  {
+    locker= PSI_server->get_thread_socket_locker(sd->m_psi, PSI_SOCKET_CONNECT);
+	if (likely(locker !=NULL))
+	  PSI_server->start_socket_wait(locker, src_file, src_line);
+  }
+#endif
+  result= connect(sd->sd, addr, len);
+#ifdef HAVE_PSI_INTERFACE
+  if (likely(locker != NULL))
+    PSI_server->end_socket_wait(locker, socket);
+#endif
+  return result;
+}
+
+/** mysql_socket_getpeername */
+
+static inline int
+inline_mysql_socket_getpeername
+(
+#ifdef HAVE_PSI_INTERFACE
+  const char *src_file, uint src_line,
+#endif
+ MYSQL_SOCKET *sd,  SOCKADDR_ARG addr, socklen_t *restrict len)
+{
+  int result;
+#ifdef HAVE_PSI_INTERFACE
+  struct PSI_socket_locker *locker= NULL;
+  if (likely(PSI_server != NULL))
+  {
+    locker= PSI_server->get_thread_socket_locker(sd->m_psi, PSI_SOCKET_BIND);
+	if (likely(locker !=NULL))
+	  PSI_server->start_socket_wait(locker, src_file, src_line);
+  }
+#endif
+  result= getpeername(sd->sd, addr, *restrict len);
+#ifdef HAVE_PSI_INTERFACE
+  if (likely(locker != NULL))
+    PSI_server->end_socket_wait(locker, socket);
+#endif
+  return result;
+}
+
+/** mysql_socket_send */
+
+static inline ssize_t
+inline_mysql_socket_send
+(
+#ifdef HAVE_PSI_INTERFACE
+  const char *src_file, uint src_line,
+#endif
+ MYSQL_SOCKET *sd, const void *buf, size_t n, int flags)
+{
+  ssize_t result;
+#ifdef HAVE_PSI_INTERFACE
+  struct PSI_socket_locker *locker= NULL;
+  if (likely(PSI_server != NULL))
+  {
+    locker= PSI_server->get_thread_socket_locker(sd->m_psi, PSI_SOCKET_SEND);
+	if (likely(locker !=NULL))
+	  PSI_server->start_socket_wait(locker, src_file, src_line);
+  }
+#endif
+  result= send(sd->sd, buf, n, flags);
+#ifdef HAVE_PSI_INTERFACE
+  if (likely(locker != NULL))
+    PSI_server->end_socket_wait(locker, socket);
+#endif
+  return result;
+}
+
+/** mysql_socket_recv */
+
+static inline ssize_t
+inline_mysql_socket_recv
+(
+#ifdef HAVE_PSI_INTERFACE
+  const char *src_file, uint src_line,
+#endif
+ MYSQL_SOCKET *sd,  void *buf, size_t n, int flags)
+{
+  ssize_t result;
+#ifdef HAVE_PSI_INTERFACE
+  struct PSI_socket_locker *locker= NULL;
+  if (likely(PSI_server != NULL))
+  {
+    locker= PSI_server->get_thread_socket_locker(sd->m_psi, PSI_SOCKET_RECV);
+	if (likely(locker !=NULL))
+	  PSI_server->start_socket_wait(locker, src_file, src_line);
+  }
+#endif
+  result= recv(sd->sd, buf, n, flags);
+#ifdef HAVE_PSI_INTERFACE
+  if (likely(locker != NULL))
+    PSI_server->end_socket_wait(locker, socket);
+#endif
+  return result;
+}
+
+/** mysql_socket_sendto */
+
+static inline ssize_t
+inline_mysql_socket_sendto
+(
+#ifdef HAVE_PSI_INTERFACE
+  const char *src_file, uint src_line,
+#endif
+ MYSQL_SOCKET *sd,  const void *buf, size_t n, int flags, CONST_SOCKADDR_ARG addr, socklen_t addr_len)
+{
+  ssize_t result;
+#ifdef HAVE_PSI_INTERFACE
+  struct PSI_socket_locker *locker= NULL;
+  if (likely(PSI_server != NULL))
+  {
+    locker= PSI_server->get_thread_socket_locker(sd->m_psi, PSI_SOCKET_SEND);
+	if (likely(locker !=NULL))
+	  PSI_server->start_socket_wait(locker, src_file, src_line);
+  }
+#endif
+  result= sendto(sd->sd, buf, n, flags, addr, addr_len);
+#ifdef HAVE_PSI_INTERFACE
+  if (likely(locker != NULL))
+    PSI_server->end_socket_wait(locker, socket);
+#endif
+  return result;
+}
+
+/** mysql_socket_recvfrom */
+
+static inline ssize_t
+inline_mysql_socket_recvfrom
+(
+#ifdef HAVE_PSI_INTERFACE
+  const char *src_file, uint src_line,
+#endif
+ MYSQL_SOCKET *sd,  void *restrict buf, size_t n, int flags, SOCKADDR_ARG addr, socklen_t *restrict addr_len)
+{
+  ssize_t result;
+#ifdef HAVE_PSI_INTERFACE
+  struct PSI_socket_locker *locker= NULL;
+  if (likely(PSI_server != NULL))
+  {
+    locker= PSI_server->get_thread_socket_locker(sd->m_psi, PSI_SOCKET_RECV);
+	if (likely(locker !=NULL))
+	  PSI_server->start_socket_wait(locker, src_file, src_line);
+  }
+#endif
+  result= recvfrom(sd->sd, buf, n, lags, addr, addr_len);
+#ifdef HAVE_PSI_INTERFACE
+  if (likely(locker != NULL))
+    PSI_server->end_socket_wait(locker, socket);
+#endif
+  return result;
+}
+
+/** mysql_socket_sendmsg */
+
+static inline ssize_t
+inline_mysql_socket_sendmsg
+(
+#ifdef HAVE_PSI_INTERFACE
+  const char *src_file, uint src_line,
+#endif
+ MYSQL_SOCKET *sd, const struct msghdr *message, int flags)
+{
+  ssize_t result;
+#ifdef HAVE_PSI_INTERFACE
+  struct PSI_socket_locker *locker= NULL;
+  if (likely(PSI_server != NULL))
+  {
+    locker= PSI_server->get_thread_socket_locker(sd->m_psi, PSI_SOCKET_SEND);
+	if (likely(locker !=NULL))
+	  PSI_server->start_socket_wait(locker, src_file, src_line);
+  }
+#endif
+  result= sendmsg(sd->sd, message, flags);
+#ifdef HAVE_PSI_INTERFACE
+  if (likely(locker != NULL))
+    PSI_server->end_socket_wait(locker, socket);
+#endif
+  return result;
+}
+
+/** mysql_socket_recvmsg */
+
+static inline ssize_t
+inline_mysql_socket_recvmsg
+(
+#ifdef HAVE_PSI_INTERFACE
+  const char *src_file, uint src_line,
+#endif
+ MYSQL_SOCKET *sd, struct msghdr *message, int flags)
+{
+  ssize_t result;
+#ifdef HAVE_PSI_INTERFACE
+  struct PSI_socket_locker *locker= NULL;
+  if (likely(PSI_server != NULL))
+  {
+    locker= PSI_server->get_thread_socket_locker(sd->m_psi, PSI_SOCKET_RECV);
+	if (likely(locker !=NULL))
+	  PSI_server->start_socket_wait(locker, src_file, src_line);
+  }
+#endif
+  result= recvmsg(sd->sd, message, flags);
+#ifdef HAVE_PSI_INTERFACE
+  if (likely(locker != NULL))
+    PSI_server->end_socket_wait(locker, socket);
+#endif
+  return result;
+}
+
+/** mysql_socket_getsockopt */
+
+static inline int
+inline_mysql_socket_getsockopt
+(
+#ifdef HAVE_PSI_INTERFACE
+  const char *src_file, uint src_line,
+#endif
+ MYSQL_SOCKET *sd, int level, int optname, void *restrict optval, socklen_t *restrict optlen)
+{
+  int result;
+#ifdef HAVE_PSI_INTERFACE
+  struct PSI_socket_locker *locker= NULL;
+  if (likely(PSI_server != NULL))
+  {
+    locker= PSI_server->get_thread_socket_locker(sd->m_psi, PSI_SOCKET_OPT);
+	if (likely(locker !=NULL))
+	  PSI_server->start_socket_wait(locker, src_file, src_line);
+  }
+#endif
+  result= getsockopt(sd->sd, level, optname, optval, optlen);
+#ifdef HAVE_PSI_INTERFACE
+  if (likely(locker != NULL))
+    PSI_server->end_socket_wait(locker, socket);
+#endif
+  return result;
+}
+
+/** mysql_socket_setsockopt */
+
+static inline int
+inline_mysql_socket_setsockopt
+(
+#ifdef HAVE_PSI_INTERFACE
+  const char *src_file, uint src_line,
+#endif
+ MYSQL_SOCKET *sd, int level, int optname, const void *optval, socklen_t optlen)
+{
+  int result;
+#ifdef HAVE_PSI_INTERFACE
+  struct PSI_socket_locker *locker= NULL;
+  if (likely(PSI_server != NULL))
+  {
+    locker= PSI_server->get_thread_socket_locker(sd->m_psi, PSI_SOCKET_OPT);
+	if (likely(locker !=NULL))
+	  PSI_server->start_socket_wait(locker, src_file, src_line);
+  }
+#endif
+  result= setsockopt(sd->sd, level, optname, optval, optlen);
+#ifdef HAVE_PSI_INTERFACE
+  if (likely(locker != NULL))
+    PSI_server->end_socket_wait(locker, socket);
+#endif
+  return result;
+}
+
+/** mysql_socket_listen */
+
+static inline int
+inline_mysql_socket_listen
+(
+#ifdef HAVE_PSI_INTERFACE
+  const char *src_file, uint src_line,
+#endif
+ MYSQL_SOCKET *sd, int n)
+{
+  int result;
+#ifdef HAVE_PSI_INTERFACE
+  struct PSI_socket_locker *locker= NULL;
+  if (likely(PSI_server != NULL))
+  {
+    locker= PSI_server->get_thread_socket_locker(sd->m_psi, PSI_SOCKET_CONNECT);
+	if (likely(locker !=NULL))
+	  PSI_server->start_socket_wait(locker, src_file, src_line);
+  }
+#endif
+  result= listen(sd->sd, n);
+#ifdef HAVE_PSI_INTERFACE
+  if (likely(locker != NULL))
+    PSI_server->end_socket_wait(locker, socket);
+#endif
+  return result;
+}
+
+/** mysql_socket_accept */
+
+static inline int
+inline_mysql_socket_accept
+(
+#ifdef HAVE_PSI_INTERFACE
+  const char *src_file, uint src_line,
+#endif
+ MYSQL_SOCKET *sd, SOCKADDR_ARG addr, socklen_t *restrict addr_len)
+{
+  int result;
+#ifdef HAVE_PSI_INTERFACE
+  struct PSI_socket_locker *locker= NULL;
+  if (likely(PSI_server != NULL))
+  {
+    locker= PSI_server->get_thread_socket_locker(sd->m_psi, PSI_SOCKET_CONNECT);
+	if (likely(locker !=NULL))
+	  PSI_server->start_socket_wait(locker, src_file, src_line);
+  }
+#endif
+  result= accept(sd->sd, addr, addr_len);
+#ifdef HAVE_PSI_INTERFACE
+  if (likely(locker != NULL))
+    PSI_server->end_socket_wait(locker, socket);
+#endif
+  return result;
+}
+
+/** mysql_socket_accept4 */
+
+static inline int
+inline_mysql_socket_accept4
+(
+#ifdef HAVE_PSI_INTERFACE
+  const char *src_file, uint src_line,
+#endif
+ MYSQL_SOCKET *sd, SOCKADDR_ARG addr, socklen_t *restrict addr_len, int flags)
+{
+  int result;
+#ifdef HAVE_PSI_INTERFACE
+  struct PSI_socket_locker *locker= NULL;
+  if (likely(PSI_server != NULL))
+  {
+    locker= PSI_server->get_thread_socket_locker(sd->m_psi, PSI_SOCKET_CONNECT);
+	if (likely(locker !=NULL))
+	  PSI_server->start_socket_wait(locker, src_file, src_line);
+  }
+#endif
+  result= accept4(sd->sd, addr, addr_len, flags);
+#ifdef HAVE_PSI_INTERFACE
+  if (likely(locker != NULL))
+    PSI_server->end_socket_wait(locker, socket);
+#endif
+  return result;
+}
+
+/** mysql_socket_shutdown */
+
+static inline int
+inline_mysql_socket_shutdown
+(
+#ifdef HAVE_PSI_INTERFACE
+  const char *src_file, uint src_line,
+#endif
+ MYSQL_SOCKET *sd, int how)
+{
+  int result;
+#ifdef HAVE_PSI_INTERFACE
+  struct PSI_socket_locker *locker= NULL;
+  if (likely(PSI_server != NULL))
+  {
+    locker= PSI_server->get_thread_socket_locker(sd->m_psi, PSI_SOCKET_CLOSE);
+	if (likely(locker !=NULL))
+	  PSI_server->start_socket_wait(locker, src_file, src_line);
+  }
+#endif
+  result= shutdown(sd->sd, how);
+#ifdef HAVE_PSI_INTERFACE
+  if (likely(locker != NULL))
+    PSI_server->end_socket_wait(locker, socket);
+#endif
+  return result;
+}
+
+/** mysql_socket_sockatmark */
+
+static inline int
+inline_mysql_socket_sockatmark
+(
+#ifdef HAVE_PSI_INTERFACE
+  const char *src_file, uint src_line,
+#endif
+  MYSQL_SOCKET *sd)
+{
+  int result;
+#ifdef HAVE_PSI_INTERFACE
+  struct PSI_socket_locker *locker= NULL;
+  if (likely(PSI_server != NULL))
+  {
+    locker= PSI_server->get_thread_socket_locker(sd->m_psi, PSI_SOCKET_STAT);
+	if (likely(locker !=NULL))
+	  PSI_server->start_socket_wait(locker, src_file, src_line);
+  }
+#endif
+  result= sockatmark(sd->sd);
+#ifdef HAVE_PSI_INTERFACE
+  if (likely(locker != NULL))
+    PSI_server->end_socket_wait(locker, socket);
+#endif
+  return result;
+}
+
+/** mysql_socket_isfdtype */
+
+static inline int
+inline_mysql_socket_isfdtype
+(
+#ifdef HAVE_PSI_INTERFACE
+  const char *src_file, uint src_line,
+#endif
+ MYSQL_SOCKET *sd,  int fdtype)
+{
+  int result;
+#ifdef HAVE_PSI_INTERFACE
+  struct PSI_socket_locker *locker= NULL;
+  if (likely(PSI_server != NULL))
+  {
+    locker= PSI_server->get_thread_socket_locker(sd->m_psi, PSI_SOCKET_STAT);
+	if (likely(locker !=NULL))
+	  PSI_server->start_socket_wait(locker, src_file, src_line);
+  }
+#endif
+  result= isfdtype(sd->sd, fdtype);
+#ifdef HAVE_PSI_INTERFACE
+  if (likely(locker != NULL))
+    PSI_server->end_socket_wait(locker, socket);
+#endif
+  return result;
+}
+
+
+
+/** @} (end of group Network_instrumentation) */
+
+#endif
+

=== modified file 'include/mysql/psi/psi.h'
--- a/include/mysql/psi/psi.h	2010-01-26 23:42:54 +0000
+++ b/include/mysql/psi/psi.h	2010-06-07 21:03:19 +0000
@@ -80,6 +80,12 @@ struct PSI_thread;
 */
 struct PSI_file;
 
+/**
+  Interface for an instrumented socket descriptor.
+  This is an opaque structure.
+*/
+struct PSI_socket;
+
 /** Entry point for the performance schema interface. */
 struct PSI_bootstrap
 {
@@ -229,6 +235,38 @@ enum PSI_file_operation
   PSI_FILE_SYNC= 16
 };
 
+/** Operation performed on an instrumented socket. */
+enum PSI_socket_operation
+{
+  /** Socket creation, as in @c socket() or @c socketpair(). */
+  PSI_SOCKET_CREATE= 0,
+
+  /** Socket connection, as in @c connect(), @c listen() and @c accept(). */
+  PSI_SOCKET_CONNECT= 1,
+
+  /** Socket bind, as in @c bind(), @c getsockname() and @c getpeername(). */
+  PSI_SOCKET_BIND= 2,
+
+  /** Socket close, as in @c shutdown(). */
+  PSI_SOCKET_CLOSE= 3,
+  /**
+    Generic socket send, such as @c send(), @c sendto(), @c sendmsg(). */
+  PSI_SOCKET_SEND= 4,
+  /**
+    Generic socket receive, such as @c recv(), @c recvfrom), @c recvmsg(). */
+  PSI_SOCKET_RECV= 5,
+
+  /** Generic socket seek, such as @c fseek() or @c seek(). */
+  PSI_SOCKET_SEEK= 6,
+
+  /** Socket options, as in @c getsockopt() and @c setsockopt(). */
+  PSI_SOCKET_OPT= 7,
+
+  /** Socket status, as in @c sockatmark() and @c isfdtype(). */
+  PSI_SOCKET_STAT= 8
+};
+
+
 /**
   Interface for an instrumented table operation.
   This is an opaque structure.
@@ -682,6 +720,15 @@ typedef struct PSI_file_locker* (*get_th
   (File file, enum PSI_file_operation op);
 
 /**
+  Get a socket instrumentation locker.
+  @param socket the socket to access
+  @param op the operation to perform
+  @return a socket locker, or NULL
+*/
+typedef struct PSI_socket_locker* (*get_thread_socket_locker_v1_t)
+  (struct PSI_socket *socket, enum PSI_socket_operation op);
+
+/**
   Record a mutex instrumentation unlock event.
   @param thread the running thread instrumentation
   @param mutex the mutex instrumentation
@@ -844,6 +891,30 @@ typedef void (*end_file_wait_v1_t)
   (struct PSI_file_locker *locker, size_t count);
 
 /**
+  Record a socket instrumentation start event.
+  @param locker a socket locker for the running thread
+  @param op socket operation to be performed
+  @param count the number of bytes requested, or 0 if not applicable
+  @param src_file the source file name
+  @param src_line the source line number
+*/
+typedef void (*start_sockett_wait_v1_t)
+  (struct PSI_socket_locker *locker, size_t count, //TBD
+   const char *src_file, uint src_line);
+
+/**
+  Record a socket instrumentation end event.
+  Note that for socket close operations, the instrumented socket handle
+  associated with the socket (which was provided to obtain a locker)
+  is invalid after this call.
+  @param locker a socket locker for the running thread
+  @param count the number of bytes actually used in the operation,
+  or 0 if not applicable, or -1 if the operation failed
+  @sa get_thread_socket_locker
+*/
+typedef void (*end_socket_wait_v1_t)
+  (struct PSI_socket_locker *locker, size_t count); //TBD
+/**
   Performance Schema Interface, version 1.
   @since PSI_VERSION_1
 */
@@ -909,6 +980,8 @@ struct PSI_v1
   get_thread_file_stream_locker_v1_t get_thread_file_stream_locker;
   /** @sa get_thread_file_descriptor_locker_v1_t. */
   get_thread_file_descriptor_locker_v1_t get_thread_file_descriptor_locker;
+  /** @sa get_thread_socket_locker_v1_t. */
+  get_thread_socket_locker_v1_t get_thread_socket_locker;
   /** @sa unlock_mutex_v1_t. */
   unlock_mutex_v1_t unlock_mutex;
   /** @sa unlock_rwlock_v1_t. */


Attachment: [text/bzr-bundle] bzr/chris.powers@oracle.com-20100607210319-jacxcdjoc9ybaepj.bundle
Thread
bzr push into mysql-next-mr-wl4896 branch (chris.powers:3146 to 3147) WL#4896Christopher Powers7 Jun