List:Commits« Previous MessageNext Message »
From:Christopher Powers Date:August 18 2011 5:59am
Subject:bzr push into mysql-trunk branch (chris.powers:3377 to 3378) WL#4896
View as plain text  
 3378 Christopher Powers	2011-08-18
      WL#4896 "Performance Schema Net IO"
      
      Yet a third condition resulting in orphaned socket instances:
      
      Even if all instrumentation is disabled, the socket still needs
      to be destroyed after closesocket() is called.
      get_thread_socket_locker() must be sensitive to this condition.

    modified:
      storage/perfschema/pfs.cc
 3377 Christopher Powers	2011-08-18
      WL#4896 "Performance Schema Net IO"
      
      Two bugs caused orphaned socket instances:
      
      1. If there is no thread instrumentation, then get_thread_socket_locker() returns a
      null locker, preventing the PFS socket from being destroyed following closesocket().
      
      2. SSL authentication calls vio_reset() for the active connection, which reset the
      PSI pointer for the corresponding socket. This prevents a locker from being created
      on a subsequent call to closesocket(), and the PFS socket is never deleted.

    modified:
      storage/perfschema/pfs.cc
      vio/vio.c
=== modified file 'storage/perfschema/pfs.cc'
--- a/storage/perfschema/pfs.cc	2011-08-18 05:29:13 +0000
+++ b/storage/perfschema/pfs.cc	2011-08-18 05:58:49 +0000
@@ -2835,17 +2835,24 @@ get_thread_socket_locker_v1(PSI_socket_l
     return NULL;
 
   DBUG_ASSERT(pfs_socket->m_class != NULL);
-  DBUG_ASSERT(!(pfs_socket->m_idle && op == PSI_SOCKET_CLOSE));
+
+  my_bool socket_close= false;
+  register uint flags= 0;
 
   if (!pfs_socket->m_enabled || pfs_socket->m_idle)
-    return NULL;
+  {
+    if (op == PSI_SOCKET_CLOSE)
+      socket_close= true;
+    else
+      return NULL;
+  }
 
-  register uint flags;
   PFS_thread *pfs_thread= pfs_socket->m_thread_owner;
 
-  if (flag_thread_instrumentation && likely(pfs_thread != NULL))
+  if (flag_thread_instrumentation && likely(pfs_thread != NULL) &&
+      likely(!socket_close))
   {
-    // PFS_thread *pfs_thread= pfs_socket->m_thread_owner;
+    //PFS_thread *pfs_thread= pfs_socket->m_thread_owner;
 
     //if (unlikely(pfs_thread == NULL))
     //  return NULL;
@@ -2857,9 +2864,7 @@ get_thread_socket_locker_v1(PSI_socket_l
     */
     if (!pfs_thread->m_enabled)
     {
-      if (op == PSI_SOCKET_CLOSE)
-        flags= 0;
-      else
+      if (op != PSI_SOCKET_CLOSE)
         return NULL;
     }
     else
@@ -2902,38 +2907,39 @@ get_thread_socket_locker_v1(PSI_socket_l
   }
   else
   {
-    if (pfs_socket->m_timed)
+    if (!socket_close)
     {
-      flags= STATE_FLAG_TIMED;
-    }
-    else
-    {
-      flags= 0;
-
-      /*
-        Even if timing is disabled, end_socket_wait() still needs a locker to
-        capture the number of bytes sent or received by the socket operation.
-        For operations that do not have a byte count, then just increment the
-        event counter and return a NULL locker.
-      */
-      switch (op)
+      if (pfs_socket->m_timed)
       {
-      case PSI_SOCKET_CONNECT:
-      case PSI_SOCKET_CREATE:
-      case PSI_SOCKET_BIND:
-      case PSI_SOCKET_SEEK:
-      case PSI_SOCKET_OPT:
-      case PSI_SOCKET_STAT:
-      case PSI_SOCKET_SHUTDOWN:
-      case PSI_SOCKET_CLOSE:
-      case PSI_SOCKET_SELECT:
+        flags= STATE_FLAG_TIMED;
+      }
+      else
+      {
+        /*
+          Even if timing is disabled, end_socket_wait() still needs a locker to
+          capture the number of bytes sent or received by the socket operation.
+          For operations that do not have a byte count, then just increment the
+          event counter and return a NULL locker.
+        */
+        switch (op)
         {
-        pfs_socket->m_socket_stat.m_io_stat.m_misc.aggregate_counted();
-        return NULL;
+        case PSI_SOCKET_CONNECT:
+        case PSI_SOCKET_CREATE:
+        case PSI_SOCKET_BIND:
+        case PSI_SOCKET_SEEK:
+        case PSI_SOCKET_OPT:
+        case PSI_SOCKET_STAT:
+        case PSI_SOCKET_SHUTDOWN:
+        case PSI_SOCKET_CLOSE:
+        case PSI_SOCKET_SELECT:
+          {
+          pfs_socket->m_socket_stat.m_io_stat.m_misc.aggregate_counted();
+          return NULL;
+          }
+          break;
+        default:
+          break;
         }
-        break;
-      default:
-        break;
       }
     }
   }

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (chris.powers:3377 to 3378) WL#4896Christopher Powers22 Aug