List:Commits« Previous MessageNext Message »
From:Christopher Powers Date:August 14 2010 9:23pm
Subject:bzr commit into mysql-next-mr-wl4896 branch (chris.powers:3162) WL#4896
View as plain text  
#At file:///home/cpowers/work/dev/dev-wl4896/mysql/ based on revid:chris.powers@stripped

 3162 Christopher Powers	2010-08-14
      WL#4896 PERFORMANCE_SCHEMA Net IO
      - Instrumented vio_read() and vio_write()
      - Added mysql_socket_vio_new() to accommodate MYSQL_SOCKET

    modified:
      include/mysql/psi/mysql_socket.h
      include/violite.h
      sql/mysqld.cc
      storage/perfschema/pfs.cc
      vio/vio.c
      vio/viosocket.c
=== modified file 'include/mysql/psi/mysql_socket.h'
--- a/include/mysql/psi/mysql_socket.h	2010-08-11 19:48:41 +0000
+++ b/include/mysql/psi/mysql_socket.h	2010-08-14 21:23:17 +0000
@@ -53,7 +53,7 @@ Foundation, Inc., 51 Franklin St, Fifth
 */
 #ifdef HAVE_PSI_INTERFACE
   #define MYSQL_SOCKET_WAIT_VARIABLES(LOCKER, STATE) \
-    PSI_socket_locker* LOCKER; \
+    struct PSI_socket_locker* LOCKER; \
     PSI_socket_locker_state STATE;
 #else
   #define MYSQL_SOCKET_WAIT_VARIABLES(LOCKER, STATE)
@@ -63,17 +63,21 @@ Foundation, Inc., 51 Franklin St, Fifth
   @def MYSQL_START_SOCKET_WAIT
   Instrumentation helper for socket waits.
   This instrumentation marks the start of a wait event.
+  @param LOCKER the locker
+  @param STATE the locker state
   @param PSI The instrumented socket
   @param OP The socket operation to be performed
-  @param INDEX The socket index used if any, or MAY_KEY.
+  @param INDEX The socket index used if any, or MAX_KEY.
   @param FLAGS Per socket operation flags.
+  @param COUNT Bytes written or -1
   @sa MYSQL_END_SOCKET_WAIT.
 */
 #ifdef HAVE_PSI_INTERFACE
-  #define MYSQL_START_SOCKET_WAIT(PSI, OP, INDEX, FLAGS) \
-    inline_mysql_start_socket_wait(PSI, OP, INDEX, FLAGS, COUNT, __FILE__, __LINE__)
+  #define MYSQL_START_SOCKET_WAIT(LOCKER, STATE, PSI, OP, INDEX, FLAGS, COUNT) \
+    LOCKER= inline_mysql_start_socket_wait(STATE, PSI, OP, INDEX, FLAGS, COUNT,\
+                                           __FILE__, __LINE__)
 #else
-  #define MYSQL_START_SOCKET_WAIT(PSI, OP, INDEX, FLAGS, COUNT) \
+  #define MYSQL_START_SOCKET_WAIT(LOCKER, STATE, PSI, OP, INDEX, FLAGS, COUNT) \
     do {} while (0)
 #endif
 
@@ -84,10 +88,10 @@ Foundation, Inc., 51 Franklin St, Fifth
   @sa MYSQL_START_SOCKET_WAIT.
 */
 #ifdef HAVE_PSI_INTERFACE
-  #define MYSQL_END_SOCKET_WAIT(L, C) \
-    inline_mysql_end_socket_wait(L, C)
+  #define MYSQL_END_SOCKET_WAIT(LOCKER, COUNT) \
+    inline_mysql_end_socket_wait(LOCKER, COUNT)
 #else
-  #define MYSQL_END_SOCKET_WAIT(L, C) \
+  #define MYSQL_END_SOCKET_WAIT(LOCKER, COUNT) \
     do {} while (0)
 #endif
 
@@ -98,13 +102,13 @@ Foundation, Inc., 51 Franklin St, Fifth
   Instrumentation calls for MYSQL_START_SOCKET_WAIT.
   @sa MYSQL_START_SOCKET_WAIT.
 */
-static inline PSI_socket_locker *
+static inline struct PSI_socket_locker*
 inline_mysql_start_socket_wait(PSI_socket_locker_state *state,
-                              PSI_socket *psi, enum PSI_socket_operation op,
-                              uint index, ulong flags, size_t count,
-                              const char *src_file, int src_line)
+                               struct PSI_socket *psi, enum PSI_socket_operation op,
+                               uint index, ulong flags, size_t count,
+                               const char *src_file, int src_line)
 {
-  PSI_socket_locker *locker= NULL;
+  struct PSI_socket_locker *locker= NULL;
 
   if (likely(PSI_server && psi))
   {
@@ -120,7 +124,7 @@ inline_mysql_start_socket_wait(PSI_socke
   @sa MYSQL_END_SOCKET_WAIT.
 */
 static inline void
-inline_mysql_end_socket_wait(PSI_socket_locker *locker, size_t count)
+inline_mysql_end_socket_wait(struct PSI_socket_locker *locker, size_t count)
 {
   if (likely(locker != NULL))
     PSI_server->end_socket_wait(locker, count);
@@ -137,10 +141,10 @@ inline_mysql_end_socket_wait(PSI_socket_
 #endif
 
 #ifdef HAVE_PSI_INTERFACE
-  #define mysql_socket_socketpair(D, T, P, FDS) \
-    inline_mysql_socket_socketpair(__FILE__, __LINE__, D, T, P, FDS)
+  #define mysql_socket_socketpair(K, D, T, P, FDS) \
+    inline_mysql_socket_socketpair(K, __FILE__, __LINE__, D, T, P, FDS)
 #else
-  #define mysql_socket_socketpair(D, T, P, FDS) \
+  #define mysql_socket_socketpair(K, D, T, P, FDS) \
     inline_mysql_socket_socketpair(D, T, P, FDS)
 #endif
 
@@ -311,7 +315,7 @@ struct st_mysql_socket
     for binary compatibility of the @c MYSQL_FILE interface.
   */
 
-  PSI_socket *m_psi;
+  struct PSI_socket *m_psi;
 };
 
 /**
@@ -354,29 +358,30 @@ static inline int
 inline_mysql_socket_socketpair
 (
 #ifdef HAVE_PSI_INTERFACE
-  const char *src_file, uint src_line,
+  PSI_socket_key key, const char *src_file, uint src_line,
 #endif
-  int domain, int type, int protocol, int fds[2])
+  int domain, int type, int protocol, MYSQL_SOCKET mysql_socket[2])
 {
-  int result = 0;
-#if 0 //TBD
-#ifdef HAVE_PSI_INTERFACE
-  PSI_socket_locker *locker= NULL;
-  PSI_socket_locker_state state;
+  int result= 0;
+  int fds[2]= {0, 0};
 
-  if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
+  mysql_socket[0].m_psi= PSI_server ? PSI_server->init_socket(key, &mysql_socket[0].fd)
+                                    : NULL;
+  mysql_socket[1].m_psi= PSI_server ? PSI_server->init_socket(key, &mysql_socket[1].fd)
+                                    : NULL;
+
+  result= socketpair(domain, type, protocol, fds);
+
+  mysql_socket[0].fd = fds[0];
+  mysql_socket[1].fd = fds[1];
+
+#ifdef HAVE_PSI_INTERFACE
+  if (likely(mysql_socket[0].m_psi != NULL && mysql_socket[1].m_psi != NULL))
   {
-    locker= PSI_server->get_thread_socket_locker(&state, mysql_socket.m_psi, PSI_SOCKET_CREATE);
-    if (likely(locker !=NULL))
-      PSI_server->start_socket_wait(locker, (size_t)0, src_file, src_line);
+    PSI_server->set_socket_descriptor(mysql_socket[0].m_psi, fds[0]);
+    PSI_server->set_socket_descriptor(mysql_socket[1].m_psi, fds[1]);
   }
 #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, (size_t)0);
-#endif
-#endif
   return result;
 }
 
@@ -388,11 +393,11 @@ inline_mysql_socket_bind
 #ifdef HAVE_PSI_INTERFACE
   const char *src_file, uint src_line,
 #endif
-  MYSQL_SOCKET mysql_socket, __CONST_SOCKADDR_ARG addr, socklen_t len)
+  MYSQL_SOCKET mysql_socket, const struct sockaddr *addr, socklen_t len)
 {
   int result;
 #ifdef HAVE_PSI_INTERFACE
-  PSI_socket_locker *locker= NULL;
+  struct PSI_socket_locker *locker= NULL;
   PSI_socket_locker_state state;
 
   if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
@@ -426,7 +431,7 @@ inline_mysql_socket_getsockname
 {
   int result;
 #ifdef HAVE_PSI_INTERFACE
-  PSI_socket_locker *locker= NULL;
+  struct PSI_socket_locker *locker= NULL;
   PSI_socket_locker_state state;
 
   if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
@@ -456,7 +461,7 @@ inline_mysql_socket_connect
 {
   int result;
 #ifdef HAVE_PSI_INTERFACE
-  PSI_socket_locker *locker= NULL;
+  struct PSI_socket_locker *locker= NULL;
   PSI_socket_locker_state state;
 
   if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
@@ -486,7 +491,7 @@ inline_mysql_socket_getpeername
 {
   int result;
 #ifdef HAVE_PSI_INTERFACE
-  PSI_socket_locker *locker= NULL;
+  struct PSI_socket_locker *locker= NULL;
   PSI_socket_locker_state state;
 
   if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
@@ -516,7 +521,7 @@ inline_mysql_socket_send
 {
   ssize_t result;
 #ifdef HAVE_PSI_INTERFACE
-  PSI_socket_locker *locker= NULL;
+  struct PSI_socket_locker *locker= NULL;
   PSI_socket_locker_state state;
 
   if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
@@ -549,7 +554,7 @@ inline_mysql_socket_recv
 {
   ssize_t result;
 #ifdef HAVE_PSI_INTERFACE
-  PSI_socket_locker *locker= NULL;
+  struct PSI_socket_locker *locker= NULL;
   PSI_socket_locker_state state;
 
   if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
@@ -582,7 +587,7 @@ inline_mysql_socket_sendto
 {
   ssize_t result;
 #ifdef HAVE_PSI_INTERFACE
-  PSI_socket_locker *locker= NULL;
+  struct PSI_socket_locker *locker= NULL;
   PSI_socket_locker_state state;
 
   if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
@@ -615,7 +620,7 @@ inline_mysql_socket_recvfrom
 {
   ssize_t result;
 #ifdef HAVE_PSI_INTERFACE
-  PSI_socket_locker *locker= NULL;
+  struct PSI_socket_locker *locker= NULL;
   PSI_socket_locker_state state;
 
   if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
@@ -648,7 +653,7 @@ inline_mysql_socket_sendmsg
 {
   ssize_t result;
 #ifdef HAVE_PSI_INTERFACE
-  PSI_socket_locker *locker= NULL;
+  struct PSI_socket_locker *locker= NULL;
   PSI_socket_locker_state state;
 
   if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
@@ -681,7 +686,7 @@ inline_mysql_socket_recvmsg
 {
   ssize_t result;
 #ifdef HAVE_PSI_INTERFACE
-  PSI_socket_locker *locker= NULL;
+  struct PSI_socket_locker *locker= NULL;
   PSI_socket_locker_state state;
 
   if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
@@ -714,7 +719,7 @@ inline_mysql_socket_getsockopt
 {
   int result;
 #ifdef HAVE_PSI_INTERFACE
-  PSI_socket_locker *locker= NULL;
+  struct PSI_socket_locker *locker= NULL;
   PSI_socket_locker_state state;
 
   if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
@@ -744,7 +749,7 @@ inline_mysql_socket_setsockopt
 {
   int result;
 #ifdef HAVE_PSI_INTERFACE
-  PSI_socket_locker *locker= NULL;
+  struct PSI_socket_locker *locker= NULL;
   PSI_socket_locker_state state;
 
   if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
@@ -774,7 +779,7 @@ inline_mysql_socket_listen
 {
   int result;
 #ifdef HAVE_PSI_INTERFACE
-  PSI_socket_locker *locker= NULL;
+  struct PSI_socket_locker *locker= NULL;
   PSI_socket_locker_state state;
 
   if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
@@ -800,11 +805,11 @@ inline_mysql_socket_accept
 #ifdef HAVE_PSI_INTERFACE
   PSI_socket_key key, const char *src_file, uint src_line,
 #endif
-  MYSQL_SOCKET socket_listen, __SOCKADDR_ARG addr, socklen_t *addr_len)
+  MYSQL_SOCKET socket_listen, struct sockaddr *addr, socklen_t *addr_len)
 {
   MYSQL_SOCKET socket_accept = {0, NULL};
 #ifdef HAVE_PSI_INTERFACE
-  PSI_socket_locker *locker= NULL;
+  struct PSI_socket_locker *locker= NULL;
   PSI_socket_locker_state state;
 
   socket_accept.m_psi = PSI_server ? PSI_server->init_socket(key, &socket_accept.fd)
@@ -843,7 +848,7 @@ inline_mysql_socket_accept4
 {
   MYSQL_SOCKET socket_accept = {0, NULL};
 #ifdef HAVE_PSI_INTERFACE
-  PSI_socket_locker *locker= NULL;
+  struct PSI_socket_locker *locker= NULL;
   PSI_socket_locker_state state;
 
   socket_accept.m_psi = PSI_server ? PSI_server->init_socket(key, &socket_accept.fd)
@@ -883,7 +888,7 @@ inline_mysql_socket_close
 {
   int result;
 #ifdef HAVE_PSI_INTERFACE
-  PSI_socket_locker *locker= NULL;
+  struct PSI_socket_locker *locker= NULL;
   PSI_socket_locker_state state;
 
   if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
@@ -913,7 +918,7 @@ inline_mysql_socket_shutdown
 {
   int result;
 #ifdef HAVE_PSI_INTERFACE
-  PSI_socket_locker *locker= NULL;
+  struct PSI_socket_locker *locker= NULL;
   PSI_socket_locker_state state;
 
   if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
@@ -943,7 +948,7 @@ inline_mysql_socket_sockatmark
 {
   int result;
 #ifdef HAVE_PSI_INTERFACE
-  PSI_socket_locker *locker= NULL;
+  struct PSI_socket_locker *locker= NULL;
   PSI_socket_locker_state state;
 
   if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
@@ -973,7 +978,7 @@ inline_mysql_socket_isfdtype
 {
   int result;
 #ifdef HAVE_PSI_INTERFACE
-  PSI_socket_locker *locker= NULL;
+  struct PSI_socket_locker *locker= NULL;
   PSI_socket_locker_state state;
 
   if (likely(PSI_server != NULL && mysql_socket.m_psi != NULL))
@@ -991,7 +996,6 @@ inline_mysql_socket_isfdtype
   return result;
 }
 
-
 /** @} (end of group Socket_instrumentation) */
 
 #endif

=== modified file 'include/violite.h'
--- a/include/violite.h	2010-04-13 15:04:45 +0000
+++ b/include/violite.h	2010-08-14 21:23:17 +0000
@@ -19,14 +19,15 @@
  */
 
 #ifndef vio_violite_h_
-#define	vio_violite_h_
+#define  vio_violite_h_
 
-#include "my_net.h"			/* needed because of struct in_addr */
+#include "my_net.h"      /* needed because of struct in_addr */
+#include <mysql/psi/mysql_socket.h>
 
 
 /* Simple vio interface in C;  The functions are implemented in violite.c */
 
-#ifdef	__cplusplus
+#ifdef  __cplusplus
 extern "C" {
 #endif /* __cplusplus */
 
@@ -45,7 +46,8 @@ enum enum_vio_type
 #define VIO_BUFFERED_READ 2                     /* use buffered read */
 #define VIO_READ_BUFFER_SIZE 16384              /* size of read buffer */
 
-Vio*	vio_new(my_socket sd, enum enum_vio_type type, uint flags);
+Vio*  vio_new(my_socket sd, enum enum_vio_type type, uint flags);
+Vio*  mysql_socket_vio_new(MYSQL_SOCKET mysql_socket, enum enum_vio_type type, uint flags);
 #ifdef __WIN__
 Vio* vio_new_win32pipe(HANDLE hPipe);
 Vio* vio_new_win32shared_memory(HANDLE handle_file_map,
@@ -59,29 +61,29 @@ Vio* vio_new_win32shared_memory(HANDLE h
 #define HANDLE void *
 #endif /* __WIN__ */
 
-void	vio_delete(Vio* vio);
-int	vio_close(Vio* vio);
+void  vio_delete(Vio* vio);
+int  vio_close(Vio* vio);
 void    vio_reset(Vio* vio, enum enum_vio_type type,
                   my_socket sd, HANDLE hPipe, uint flags);
-size_t	vio_read(Vio *vio, uchar *	buf, size_t size);
+size_t  vio_read(Vio *vio, uchar *  buf, size_t size);
 size_t  vio_read_buff(Vio *vio, uchar * buf, size_t size);
-size_t	vio_write(Vio *vio, const uchar * buf, size_t size);
-int	vio_blocking(Vio *vio, my_bool onoff, my_bool *old_mode);
-my_bool	vio_is_blocking(Vio *vio);
+size_t  vio_write(Vio *vio, const uchar * buf, size_t size);
+int  vio_blocking(Vio *vio, my_bool onoff, my_bool *old_mode);
+my_bool  vio_is_blocking(Vio *vio);
 /* setsockopt TCP_NODELAY at IPPROTO_TCP level, when possible */
-int	vio_fastsend(Vio *vio);
+int  vio_fastsend(Vio *vio);
 /* setsockopt SO_KEEPALIVE at SOL_SOCKET level, when possible */
-int	vio_keepalive(Vio *vio, my_bool	onoff);
+int  vio_keepalive(Vio *vio, my_bool  onoff);
 /* Whenever we should retry the last read/write operation. */
-my_bool	vio_should_retry(Vio *vio);
+my_bool  vio_should_retry(Vio *vio);
 /* Check that operation was timed out */
-my_bool	vio_was_interrupted(Vio *vio);
+my_bool  vio_was_interrupted(Vio *vio);
 /* Short text description of the socket for those, who are curious.. */
 const char* vio_description(Vio *vio);
 /* Return the type of the connection */
 enum enum_vio_type vio_type(Vio* vio);
 /* Return last error number */
-int	vio_errno(Vio*vio);
+int  vio_errno(Vio*vio);
 /* Get socket number */
 my_socket vio_fd(Vio*vio);
 /* Remote peer's address and name in text form */
@@ -137,37 +139,37 @@ int sslconnect(struct st_VioSSLFd*, Vio
 
 struct st_VioSSLFd
 *new_VioSSLConnectorFd(const char *key_file, const char *cert_file,
-		       const char *ca_file,  const char *ca_path,
-		       const char *cipher);
+           const char *ca_file,  const char *ca_path,
+           const char *cipher);
 struct st_VioSSLFd
 *new_VioSSLAcceptorFd(const char *key_file, const char *cert_file,
-		      const char *ca_file,const char *ca_path,
-		      const char *cipher, enum enum_ssl_init_error* error);
+          const char *ca_file,const char *ca_path,
+          const char *cipher, enum enum_ssl_init_error* error);
 void free_vio_ssl_acceptor_fd(struct st_VioSSLFd *fd);
 #endif /* ! EMBEDDED_LIBRARY */
 #endif /* HAVE_OPENSSL */
 
 void vio_end(void);
 
-#ifdef	__cplusplus
+#ifdef  __cplusplus
 }
 #endif
 
 #if !defined(DONT_MAP_VIO)
-#define vio_delete(vio) 			(vio)->viodelete(vio)
-#define vio_errno(vio)	 			(vio)->vioerrno(vio)
+#define vio_delete(vio)       (vio)->viodelete(vio)
+#define vio_errno(vio)         (vio)->vioerrno(vio)
 #define vio_read(vio, buf, size)                ((vio)->read)(vio,buf,size)
 #define vio_write(vio, buf, size)               ((vio)->write)(vio, buf, size)
 #define vio_blocking(vio, set_blocking_mode, old_mode)\
- 	(vio)->vioblocking(vio, set_blocking_mode, old_mode)
-#define vio_is_blocking(vio) 			(vio)->is_blocking(vio)
-#define vio_fastsend(vio)			(vio)->fastsend(vio)
-#define vio_keepalive(vio, set_keep_alive)	(vio)->viokeepalive(vio, set_keep_alive)
-#define vio_should_retry(vio) 			(vio)->should_retry(vio)
-#define vio_was_interrupted(vio) 		(vio)->was_interrupted(vio)
-#define vio_close(vio)				((vio)->vioclose)(vio)
-#define vio_peer_addr(vio, buf, prt, buflen)	(vio)->peer_addr(vio, buf, prt, buflen)
-#define vio_timeout(vio, which, seconds)	(vio)->timeout(vio, which, seconds)
+   (vio)->vioblocking(vio, set_blocking_mode, old_mode)
+#define vio_is_blocking(vio)       (vio)->is_blocking(vio)
+#define vio_fastsend(vio)      (vio)->fastsend(vio)
+#define vio_keepalive(vio, set_keep_alive)  (vio)->viokeepalive(vio, set_keep_alive)
+#define vio_should_retry(vio)       (vio)->should_retry(vio)
+#define vio_was_interrupted(vio)     (vio)->was_interrupted(vio)
+#define vio_close(vio)        ((vio)->vioclose)(vio)
+#define vio_peer_addr(vio, buf, prt, buflen)  (vio)->peer_addr(vio, buf, prt, buflen)
+#define vio_timeout(vio, which, seconds)  (vio)->timeout(vio, which, seconds)
 #define vio_poll_read(vio, timeout)             (vio)->poll_read(vio, timeout)
 #define vio_is_connected(vio)                   (vio)->is_connected(vio)
 #endif /* !defined(DONT_MAP_VIO) */
@@ -187,20 +189,20 @@ enum SSL_type
 /* This structure is for every connection on both sides */
 struct st_vio
 {
-  my_socket		sd;		/* my_socket - real or imaginary */
-  HANDLE hPipe;
-  my_bool		localhost;	/* Are we from localhost? */
-  int			fcntl_mode;	/* Buffered fcntl(sd,F_GETFL) */
-  struct sockaddr_storage	local;		/* Local internet address */
-  struct sockaddr_storage	remote;		/* Remote internet address */
-  int addrLen;                          /* Length of remote address */
-  enum enum_vio_type	type;		/* Type of connection */
-  char			desc[30];	/* String description */
-  char                  *read_buffer;   /* buffer for vio_read_buff */
-  char                  *read_pos;      /* start of unfetched data in the
-                                           read buffer */
-  char                  *read_end;      /* end of unfetched data */
-  /* function pointers. They are similar for socket/SSL/whatever */
+  my_socket     sd;                 /* my_socket - real or imaginary */
+  MYSQL_SOCKET  mysql_socket;       /* socket handle for performance schema */
+  HANDLE        hPipe;
+  my_bool       localhost;          /* Are we from localhost? */
+  int           fcntl_mode;         /* Buffered fcntl(sd,F_GETFL) */
+  struct sockaddr_storage  local;   /* Local internet address */
+  struct sockaddr_storage  remote;  /* Remote internet address */
+  int    addrLen;                   /* Length of remote address */
+  enum   enum_vio_type  type;       /* Type of connection */
+  char   desc[30];       /* String description */
+  char   *read_buffer;   /* buffer for vio_read_buff */
+  char   *read_pos;      /* start of unfetched data in the read buffer */
+  char   *read_end;      /* end of unfetched data */
+  /* Function pointers. They are similar for socket/SSL/whatever. */
   void    (*viodelete)(Vio*);
   int     (*vioerrno)(Vio*);
   size_t  (*read)(Vio*, uchar *, size_t);
@@ -214,11 +216,11 @@ struct st_vio
   my_bool (*should_retry)(Vio*);
   my_bool (*was_interrupted)(Vio*);
   int     (*vioclose)(Vio*);
-  void	  (*timeout)(Vio*, unsigned int which, unsigned int timeout);
+  void    (*timeout)(Vio*, unsigned int which, unsigned int timeout);
   my_bool (*poll_read)(Vio *vio, uint timeout);
   my_bool (*is_connected)(Vio*);
 #ifdef HAVE_OPENSSL
-  void	  *ssl_arg;
+  void    *ssl_arg;
 #endif
 #ifdef HAVE_SMEM
   HANDLE  handle_file_map;

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2010-08-04 15:47:50 +0000
+++ b/sql/mysqld.cc	2010-08-14 21:23:17 +0000
@@ -5452,7 +5452,7 @@ void handle_connections_sockets()
       (void) mysql_socket_close(new_sock);
       continue;
     }
-    if (!(vio_tmp=vio_new(mysql_socket_getfd(new_sock), //TBD cwp
+    if (!(vio_tmp=mysql_socket_vio_new(new_sock,
           mysql_socket_getfd(sock) == mysql_socket_getfd(unix_sock) ? VIO_TYPE_SOCKET :
           VIO_TYPE_TCPIP,
           mysql_socket_getfd(sock) == mysql_socket_getfd(unix_sock) ? VIO_LOCALHOST: 0)) ||

=== modified file 'storage/perfschema/pfs.cc'
--- a/storage/perfschema/pfs.cc	2010-08-11 19:48:41 +0000
+++ b/storage/perfschema/pfs.cc	2010-08-14 21:23:17 +0000
@@ -1035,12 +1035,12 @@ init_socket_v1(PSI_socket_key key, const
   PFS_thread *pfs_thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
   if (unlikely(pfs_thread == NULL))
     return NULL;
-  if (! pfs_thread->m_enabled)
+  if (!pfs_thread->m_enabled)
     return NULL;
   klass= find_socket_class(key);
   if (unlikely(klass == NULL))
     return NULL;
-  if (! klass->m_enabled)
+  if (!klass->m_enabled)
     return NULL;
   pfs= create_socket(klass, identity);
   return reinterpret_cast<PSI_socket *> (pfs);
@@ -2328,8 +2328,7 @@ static void end_socket_wait_v1(PSI_socke
   wait->m_thread->m_wait_locker_count--;
 }
 
-static void set_socket_descriptor_v1(PSI_socket *socket,
-                                         uint fd)
+static void set_socket_descriptor_v1(PSI_socket *socket, uint fd)
 {
   DBUG_ASSERT(socket);
   PFS_socket *pfs= reinterpret_cast<PFS_socket*>(socket);

=== modified file 'vio/vio.c'
--- a/vio/vio.c	2010-07-08 21:20:08 +0000
+++ b/vio/vio.c	2010-08-14 21:23:17 +0000
@@ -155,6 +155,11 @@ static void vio_init(Vio* vio, enum enum
   vio->timeout          =vio_timeout;
   vio->poll_read        =vio_poll_read;
   vio->is_connected     =vio_is_connected;
+
+#ifdef HAVE_PSI_INTERFACE
+  vio->mysql_socket.fd= sd; // TBDs
+  vio->mysql_socket.m_psi= NULL;
+#endif
   DBUG_VOID_RETURN;
 }
 
@@ -168,6 +173,17 @@ void vio_reset(Vio* vio, enum enum_vio_t
   vio_init(vio, type, sd, hPipe, flags);
 }
 
+Vio *mysql_socket_vio_new(MYSQL_SOCKET mysql_socket, enum enum_vio_type type, uint flags)
+{
+  Vio *vio = vio_new(mysql_socket_getfd(mysql_socket), type, flags);
+
+  if (vio)
+  {
+    vio->mysql_socket= mysql_socket;
+  }
+
+  return (vio);
+}
 
 /* Open the socket or TCP/IP connection and read the fnctl() status */
 

=== modified file 'vio/viosocket.c'
--- a/vio/viosocket.c	2010-06-22 23:15:38 +0000
+++ b/vio/viosocket.c	2010-08-14 21:23:17 +0000
@@ -28,14 +28,15 @@ int vio_errno(Vio *vio __attribute__((un
 }
 
 
-size_t vio_read(Vio * vio, uchar* buf, size_t size)
+size_t vio_read(Vio* vio, uchar* buf, size_t size)
 {
   size_t r;
+  size_t bytes_read= 0;
+  MYSQL_SOCKET_WAIT_VARIABLES(locker, state) /* no ';' */
   DBUG_ENTER("vio_read");
   DBUG_PRINT("enter", ("sd: %d  buf: 0x%lx  size: %u", vio->sd, (long) buf,
-                       (uint) size));
-  struct PSI_socket_locker *locker;
-  //locker= MYSQL_START_SOCKET_WAIT(m_psi, PSI_SOCKET_RECV, MAX_KEY, 0);
+                      (uint) size));
+  MYSQL_START_SOCKET_WAIT(locker, &state, vio->mysql_socket.m_psi, PSI_SOCKET_RECV, 0, 0, 0);
 
   /* Ensure nobody uses vio_read_buff and vio_read simultaneously */
   DBUG_ASSERT(vio->read_end == vio->read_pos);
@@ -45,6 +46,12 @@ size_t vio_read(Vio * vio, uchar* buf, s
   errno=0;					/* For linux */
   r = read(vio->sd, buf, size);
 #endif /* __WIN__ */
+
+#ifdef HAVE_PSI_INTERFACE
+  bytes_read= (r != (size_t)-1) ? r : 0;
+#endif
+  MYSQL_END_SOCKET_WAIT(locker, bytes_read);
+
 #ifndef DBUG_OFF
   if (r == (size_t) -1)
   {
@@ -52,8 +59,6 @@ size_t vio_read(Vio * vio, uchar* buf, s
   }
 #endif /* DBUG_OFF */
 
-  //MYSQL_END_SOCKET_WAIT(locker);
-
   DBUG_PRINT("exit", ("%ld", (long) r));
   DBUG_RETURN(r);
 }
@@ -107,14 +112,24 @@ size_t vio_read_buff(Vio *vio, uchar* bu
 size_t vio_write(Vio * vio, const uchar* buf, size_t size)
 {
   size_t r;
+  size_t bytes_written= 0;
+  MYSQL_SOCKET_WAIT_VARIABLES(locker, state) /* no ';' */
   DBUG_ENTER("vio_write");
   DBUG_PRINT("enter", ("sd: %d  buf: 0x%lx  size: %u", vio->sd, (long) buf,
                        (uint) size));
+  MYSQL_START_SOCKET_WAIT(locker, &state, vio->mysql_socket.m_psi, PSI_SOCKET_SEND, 0, 0, 0);
+
 #ifdef __WIN__
   r = send(vio->sd, buf, size,0);
 #else
   r = write(vio->sd, buf, size);
 #endif /* __WIN__ */
+
+#ifdef HAVE_PSI_INTERFACE
+  bytes_written= (r != (size_t)-1) ? r : 0;
+#endif
+MYSQL_END_SOCKET_WAIT(locker, bytes_written);
+
 #ifndef DBUG_OFF
   if (r == (size_t) -1)
   {
@@ -193,7 +208,7 @@ vio_is_blocking(Vio * vio)
 }
 
 
-int vio_fastsend(Vio * vio __attribute__((unused)))
+int vio_fastsend(Vio* vio __attribute__((unused)))
 {
   int r=0;
   DBUG_ENTER("vio_fastsend");


Attachment: [text/bzr-bundle] bzr/chris.powers@oracle.com-20100814212317-h0wtudoln5h11sdk.bundle
Thread
bzr commit into mysql-next-mr-wl4896 branch (chris.powers:3162) WL#4896Christopher Powers14 Aug