List:Commits« Previous MessageNext Message »
From:Christopher Powers Date:April 19 2011 7:59pm
Subject:bzr push into mysql-trunk branch (chris.powers:3282 to 3283) WL#4896
View as plain text  
 3283 cpowers	2011-04-19
      WL#4896 "Performance Schema Net IO"
      
      - Fixed socket version bug
      - Windows: Replaced inet_ntop() with getnameinfo()
      - Use #define HAVE_IPV6
      - Removed redundant includes of arpa/inet.h and winsock2.h
      - Streamlined aggregate() methods in pfs_stat.h
      - Deleted unused set() methods in table_helper.h

    modified:
      storage/perfschema/pfs.cc
      storage/perfschema/pfs_global.cc
      storage/perfschema/pfs_instr.h
      storage/perfschema/pfs_stat.h
      storage/perfschema/table_helper.h
 3282 cpowers	2011-04-19
      WL#4896 "Performance Schema Net IO"
      
      - Updated unit test to handle socket with no thread owner

    modified:
      storage/perfschema/unittest/pfs-t.cc
=== modified file 'storage/perfschema/pfs.cc'
--- a/storage/perfschema/pfs.cc	2011-04-14 01:21:41 +0000
+++ b/storage/perfschema/pfs.cc	2011-04-19 19:46:36 +0000
@@ -17,11 +17,6 @@
   @file storage/perfschema/pfs.cc
   The performance schema implementation of all instruments.
 */
-#ifdef __WIN__
-  #include <winsock2.h>
-#else
-  #include <arpa/inet.h>
-#endif
 #include "my_global.h"
 #include "thr_lock.h"
 #include "mysql/psi/psi.h"
@@ -2839,15 +2834,16 @@ get_thread_socket_locker_v1(PSI_socket_l
       wait->m_event_type= EVENT_TYPE_WAIT;
       wait->m_nesting_event_id= parent_event->m_event_id;
       wait->m_nesting_event_id= parent_event->m_event_type;
-      wait->m_thread=      pfs_thread;
-      wait->m_class=       klass;
-      wait->m_timer_start= 0;
-      wait->m_timer_end=   0;
+      wait->m_thread=       pfs_thread;
+      wait->m_class=        klass;
+      wait->m_timer_start=  0;
+      wait->m_timer_end=    0;
       wait->m_object_instance_addr= pfs_socket->m_identity;
-      wait->m_weak_socket= pfs_socket;
-      wait->m_event_id=    pfs_thread->m_event_id++;
-      wait->m_operation=   socket_operation_map[static_cast<int>(op)];
-      wait->m_wait_class=  WAIT_CLASS_SOCKET;
+      wait->m_weak_socket=  pfs_socket;
+      wait->m_weak_version= pfs_socket->get_version();
+      wait->m_event_id=     pfs_thread->m_event_id++;
+      wait->m_operation=    socket_operation_map[static_cast<int>(op)];
+      wait->m_wait_class=   WAIT_CLASS_SOCKET;
 
       pfs_thread->m_events_waits_count++;
     }

=== modified file 'storage/perfschema/pfs_global.cc'
--- a/storage/perfschema/pfs_global.cc	2011-03-18 22:24:30 +0000
+++ b/storage/perfschema/pfs_global.cc	2011-04-19 19:46:36 +0000
@@ -25,7 +25,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-// TBD: check this
 #ifdef __WIN__
   #include <winsock2.h>
 #else
@@ -74,38 +73,7 @@ void pfs_print_error(const char *format,
   fflush(stderr);
 }
 
-#ifdef __WIN__
-
-/** inet_ntop() does not exist in Windows. Defined here for convenience. */
-
-const char *inet_ntop(int af, const void *src, char *host, socklen_t hostlen)
-{
-  if (af == AF_INET)
-  {
-    struct sockaddr_in in;
-    memset(&in, 0, sizeof(in));
-    in.sin_family = AF_INET;
-    memcpy(&in.sin_addr, src, sizeof(struct in_addr));
-    /** Convert ip address into readable form. Do not do a reverse DNS lookup. */
-    getnameinfo((struct sockaddr *)&in, sizeof(struct sockaddr_in), host, hostlen, NULL, 0, NI_NUMERICHOST);
-    return host;
-  }
-  else if (af == AF_INET6)
-  {
-    struct sockaddr_in6 in;
-    memset(&in, 0, sizeof(in));
-    in.sin6_family = AF_INET6;
-    memcpy(&in.sin6_addr, src, sizeof(struct in_addr6));
-    /** Convert ip address into readable form. Do not do a reverse DNS lookup. */
-    getnameinfo((struct sockaddr *)&in, sizeof(struct sockaddr_in6), host, hostlen, NULL, 0, NI_NUMERICHOST);
-    return host;
-  }
-  return NULL;
-}
-
-#endif // __WIN32
-
-/** Convert raw ip address into readable format */ // TBD: review this
+/** Convert raw ip address into readable format. Do not do a reverse DNS lookup. */
 
 uint pfs_get_socket_address(char *host,
                             uint host_len,
@@ -127,20 +95,34 @@ uint pfs_get_socket_address(char *host,
       if (host_len < INET_ADDRSTRLEN+1)
         return 0;
       struct sockaddr_in *sa4= (struct sockaddr_in *)(src_addr);
+    #ifdef __WIN__
+      /* Older versions of Windows do not support inet_ntop() */
+      getnameinfo((struct sockaddr *)sa4, sizeof(struct sockaddr_in),
+                  host, host_len, NULL, 0, NI_NUMERICHOST);
+    #else
       inet_ntop(AF_INET, &(sa4->sin_addr), host, INET_ADDRSTRLEN);
+    #endif
       *port= ntohs(sa4->sin_port);
     }
     break;
 
+#ifdef HAVE_IPV6
     case AF_INET6:
     {
       if (host_len < INET6_ADDRSTRLEN+1)
         return 0;
       struct sockaddr_in6 *sa6= (struct sockaddr_in6 *)(src_addr);
+    #ifdef __WIN__
+      /* Older versions of Windows do not support inet_ntop() */
+      getnameinfo((struct sockaddr *)sa6, sizeof(struct sockaddr_in),
+                  host, host_len, NULL, 0, NI_NUMERICHOST);
+    #else
       inet_ntop(AF_INET6, &(sa6->sin6_addr), host, INET6_ADDRSTRLEN);
+    #endif
       *port= ntohs(sa6->sin6_port);
     }
     break;
+#endif
 
     default:
       break;

=== modified file 'storage/perfschema/pfs_instr.h'
--- a/storage/perfschema/pfs_instr.h	2011-04-14 01:36:24 +0000
+++ b/storage/perfschema/pfs_instr.h	2011-04-19 19:46:36 +0000
@@ -32,7 +32,7 @@ struct PFS_socket_class;
 #ifdef __WIN__
 #include <winsock2.h>
 #else
-#include <netinet/in.h>
+#include <arpa/inet.h>
 #endif
 #include "pfs_lock.h"
 #include "pfs_stat.h"

=== modified file 'storage/perfschema/pfs_stat.h'
--- a/storage/perfschema/pfs_stat.h	2011-04-14 01:21:41 +0000
+++ b/storage/perfschema/pfs_stat.h	2011-04-19 19:46:36 +0000
@@ -157,11 +157,8 @@ struct PFS_byte_stat : public PFS_single
   /* Aggregate individual wait time, event count and byte count */
   inline void aggregate(ulonglong wait, ulonglong bytes)
   {
-    if (wait != 0)
-      aggregate_value(wait);
-
-    if (bytes != 0)
-      m_bytes+= bytes;
+    aggregate_value(wait);
+    m_bytes+= bytes;
   }
 
   /* Aggregate wait stats and event count */
@@ -180,9 +177,7 @@ struct PFS_byte_stat : public PFS_single
   inline void aggregate_counted(ulonglong bytes)
   {
     PFS_single_stat::aggregate_counted();
-
-    if (bytes != 0)
-      m_bytes+= bytes;
+    m_bytes+= bytes;
   }
     
   PFS_byte_stat()

=== modified file 'storage/perfschema/table_helper.h'
--- a/storage/perfschema/table_helper.h	2011-03-28 23:37:10 +0000
+++ b/storage/perfschema/table_helper.h	2011-04-19 19:46:36 +0000
@@ -151,27 +151,6 @@ struct PFS_stat_row
     }
   }
 
-  /** Build a row with count values from a memory buffer. */
-  inline void set(const PFS_single_stat *stat)
-  {
-    m_count= stat->m_count;
-
-    if (m_count)
-    {
-      m_sum= stat->m_sum;
-      m_min= stat->m_min;
-      m_max= stat->m_max;
-      m_avg= (stat->m_sum / m_count);
-    }
-    else
-    {
-      m_sum= 0;
-      m_min= 0;
-      m_avg= 0;
-      m_max= 0;
-    }
-  }
-
   /** Set a table field from the row. */
   void set_field(uint index, Field *f)
   {


Attachment: [text/bzr-bundle] bzr/cpowers@tma-1-20110419194636-kpp0yk748dsjz8i1.bundle
Thread
bzr push into mysql-trunk branch (chris.powers:3282 to 3283) WL#4896Christopher Powers19 Apr