List:Commits« Previous MessageNext Message »
From:Christopher Powers Date:March 21 2011 2:08am
Subject:bzr push into mysql-trunk branch (chris.powers:3269)
View as plain text  
 3269 cpowers	2011-03-20 [merge]
      merge

    modified:
      mysql-test/suite/perfschema/r/pfs_upgrade_lc0.result
=== modified file 'storage/perfschema/table_socket_instances.h'
--- a/storage/perfschema/table_socket_instances.h	2011-03-19 01:36:46 +0000
+++ b/storage/perfschema/table_socket_instances.h	2011-03-21 02:01:31 +0000
@@ -53,7 +53,7 @@ struct row_socket_instances
   /** Socket state: ACTIVE or IDLE */
   PSI_socket_state m_state;
 
-  row_socket_instances() {m_thread_id= false;}
+  row_socket_instances() {m_thread_id_set= false;}
 };
 
 /** Table PERFORMANCE_SCHEMA.SOCKET_INSTANCES. */

=== modified file 'storage/perfschema/unittest/pfs-t.cc'
--- a/storage/perfschema/unittest/pfs-t.cc	2011-03-08 17:24:34 +0000
+++ b/storage/perfschema/unittest/pfs-t.cc	2011-03-21 02:01:31 +0000
@@ -87,6 +87,7 @@ void test_bootstrap()
   param.m_thread_class_sizing= 0;
   param.m_table_share_sizing= 0;
   param.m_file_class_sizing= 0;
+  param.m_socket_class_sizing= 0;
   param.m_mutex_sizing= 0;
   param.m_rwlock_sizing= 0;
   param.m_cond_sizing= 0;
@@ -94,6 +95,7 @@ void test_bootstrap()
   param.m_table_sizing= 0;
   param.m_file_sizing= 0;
   param.m_file_handle_sizing= 0;
+  param.m_socket_sizing= 0;
   param.m_events_waits_history_sizing= 0;
   param.m_events_waits_history_long_sizing= 0;
   param.m_setup_actor_sizing= 0;
@@ -131,6 +133,7 @@ PSI * load_perfschema()
   param.m_thread_class_sizing= 10;
   param.m_table_share_sizing= 10;
   param.m_file_class_sizing= 10;
+  param.m_socket_class_sizing= 10;
   param.m_mutex_sizing= 10;
   param.m_rwlock_sizing= 10;
   param.m_cond_sizing= 10;
@@ -138,6 +141,7 @@ PSI * load_perfschema()
   param.m_table_sizing= 10;
   param.m_file_sizing= 10;
   param.m_file_handle_sizing= 50;
+  param.m_socket_sizing= 10;
   param.m_events_waits_history_sizing= 10;
   param.m_events_waits_history_long_sizing= 10;
   param.m_setup_actor_sizing= 0;
@@ -487,6 +491,72 @@ void test_bad_registration()
   psi->register_file("X", bad_file_3, 1);
   ok(dummy_file_key == 2, "assigned key");
 
+ /*
+    Test that length('wait/io/socket/' (15) + category + '/' (1)) < 32
+    --> category can be up to 15 chars for a socket.
+  */
+
+  PSI_socket_key dummy_socket_key= 9999;
+  PSI_socket_info bad_socket_1[]=
+  {
+    { & dummy_socket_key, "X", 0}
+  };
+
+  psi->register_socket("/", bad_socket_1, 1);
+  ok(dummy_socket_key == 0, "zero key");
+  dummy_socket_key= 9999;
+  psi->register_socket("a/", bad_socket_1, 1);
+  ok(dummy_socket_key == 0, "zero key");
+  dummy_socket_key= 9999;
+  psi->register_socket("/b", bad_socket_1, 1);
+  ok(dummy_socket_key == 0, "zero key");
+  dummy_socket_key= 9999;
+  psi->register_socket("a/b", bad_socket_1, 1);
+  ok(dummy_socket_key == 0, "zero key");
+  dummy_socket_key= 9999;
+  psi->register_socket("1234567890123456", bad_socket_1, 1);
+  ok(dummy_socket_key == 0, "zero key");
+  dummy_socket_key= 9999;
+  psi->register_socket("123456789012345", bad_socket_1, 1);
+  ok(dummy_socket_key == 1, "assigned key");
+
+  /*
+    Test that length('wait/io/socket/' (15) + category + '/' (1) + name) <= 128
+    --> category + name can be up to 112 chars for a socket.
+  */
+
+  dummy_socket_key= 9999;
+  PSI_socket_info bad_socket_2[]=
+  {
+    { & dummy_socket_key,
+      /* 112 chars name */
+      "12345678901234567890123456789012345678901234567890"
+      "12345678901234567890123456789012345678901234567890"
+      "123456789012",
+      0}
+  };
+
+  psi->register_socket("X", bad_socket_2, 1);
+  ok(dummy_socket_key == 0, "zero key");
+
+  dummy_socket_key= 9999;
+  PSI_socket_info bad_socket_3[]=
+  {
+    { & dummy_socket_key,
+      /* 111 chars name */
+      "12345678901234567890123456789012345678901234567890"
+      "12345678901234567890123456789012345678901234567890"
+      "12345678901",
+      0}
+  };
+
+  psi->register_socket("XX", bad_socket_3, 1);
+  ok(dummy_socket_key == 0, "zero key");
+
+  psi->register_socket("X", bad_socket_3, 1);
+  ok(dummy_socket_key == 2, "assigned key");
+
+
   shutdown_performance_schema();
 }
 
@@ -522,6 +592,12 @@ void test_init_disabled()
     { & file_key_A, "F-A", 0}
   };
 
+  PSI_socket_key socket_key_A;
+  PSI_socket_info all_socket[]=
+  {
+    { & socket_key_A, "S-A", 0}
+  };
+
   PSI_thread_key thread_key_1;
   PSI_thread_info all_thread[]=
   {
@@ -532,16 +608,19 @@ void test_init_disabled()
   psi->register_rwlock("test", all_rwlock, 1);
   psi->register_cond("test", all_cond, 1);
   psi->register_file("test", all_file, 1);
+  psi->register_socket("test", all_socket, 1);
   psi->register_thread("test", all_thread, 1);
 
   PFS_mutex_class *mutex_class_A;
   PFS_rwlock_class *rwlock_class_A;
   PFS_cond_class *cond_class_A;
   PFS_file_class *file_class_A;
+  PFS_socket_class *socket_class_A;
   PSI_mutex *mutex_A1;
   PSI_rwlock *rwlock_A1;
   PSI_cond *cond_A1;
   PFS_file *file_A1;
+  PSI_socket *socket_A1;
   PSI_thread *thread_1;
 
   /* Preparation */
@@ -562,6 +641,9 @@ void test_init_disabled()
   file_class_A= find_file_class(file_key_A);
   ok(file_class_A != NULL, "file class A");
 
+  socket_class_A= find_socket_class(socket_key_A);
+  ok(socket_class_A != NULL, "socket class A");
+
   /* Pretend thread T-1 is running, and disabled, with thread_instrumentation */
   /* ------------------------------------------------------------------------ */
 
@@ -652,6 +734,26 @@ void test_init_disabled()
   file_A1= lookup_file_by_name("foo");
   ok(file_A1 == NULL, "not instrumented");
 
+  /* disabled S-A + disabled T-1: no instrumentation */
+
+  socket_class_A->m_enabled= false;
+  socket_A1= psi->init_socket(socket_key_A, NULL);
+  ok(socket_A1 == NULL, "socket_A1 not instrumented");
+
+  /* enabled S-A + disabled T-1: instrumentation (for later) */
+
+  socket_class_A->m_enabled= true;
+  socket_A1= psi->init_socket(socket_key_A, NULL);
+  ok(socket_A1 != NULL, "socket_A1 instrumented");
+
+  /* broken key + disabled T-1: no instrumentation */
+
+  socket_class_A->m_enabled= true;
+  socket_A1= psi->init_socket(0, NULL);
+  ok(socket_A1 == NULL, "socket key 0 not instrumented");
+  socket_A1= psi->init_socket(99, NULL);
+  ok(socket_A1 == NULL, "broken socket key not instrumented");
+  
   /* Pretend thread T-1 is enabled */
   /* ----------------------------- */
 
@@ -760,6 +862,27 @@ void test_init_disabled()
   file_A1= lookup_file_by_name("foo");
   ok(file_A1 == NULL, "broken file key not instrumented");
 
+  /* disabled S-A + enabled T-1: no instrumentation */
+
+  socket_class_A->m_enabled= false;
+  socket_A1= psi->init_socket(socket_key_A, NULL);
+  ok(socket_A1 == NULL, "not instrumented");
+
+  /* enabled S-A + enabled T-1: instrumentation */
+
+  socket_class_A->m_enabled= true;
+  socket_A1= psi->init_socket(socket_key_A, NULL);
+  ok(socket_A1 != NULL, "instrumented");
+  psi->destroy_socket(socket_A1);
+
+  /* broken key + enabled T-1: no instrumentation */
+
+  socket_class_A->m_enabled= true;
+  socket_A1= psi->init_socket(0, NULL);
+  ok(socket_A1 == NULL, "not instrumented");
+  socket_A1= psi->init_socket(99, NULL);
+  ok(socket_A1 == NULL, "not instrumented");
+
   /* Pretend the running thread is not instrumented */
   /* ---------------------------------------------- */
 
@@ -849,6 +972,26 @@ void test_init_disabled()
   file_A1= lookup_file_by_name("foo");
   ok(file_A1 == NULL, "not instrumented");
 
+  /* disabled S-A + unknown thread: no instrumentation */
+
+  socket_class_A->m_enabled= false;
+  socket_A1= psi->init_socket(socket_key_A, NULL);
+  ok(socket_A1 == NULL, "socket_A1 not instrumented");
+
+  /* enabled S-A + unknown thread: instrumentation (for later) */
+
+  socket_class_A->m_enabled= true;
+  socket_A1= psi->init_socket(socket_key_A, NULL);
+  ok(socket_A1 != NULL, "socket_A1 instrumented");
+
+  /* broken key + unknown thread: no instrumentation */
+
+  socket_class_A->m_enabled= true;
+  socket_A1= psi->init_socket(0, NULL);
+  ok(socket_A1 == NULL, "socket key 0 not instrumented");
+  socket_A1= psi->init_socket(99, NULL);
+  ok(socket_A1 == NULL, "broken socket key not instrumented");
+  
   shutdown_performance_schema();
 }
 
@@ -884,6 +1027,12 @@ void test_locker_disabled()
     { & file_key_A, "F-A", 0}
   };
 
+  PSI_socket_key socket_key_A;
+  PSI_socket_info all_socket[]=
+  {
+    { & socket_key_A, "S-A", 0}
+  };
+
   PSI_thread_key thread_key_1;
   PSI_thread_info all_thread[]=
   {
@@ -894,16 +1043,19 @@ void test_locker_disabled()
   psi->register_rwlock("test", all_rwlock, 1);
   psi->register_cond("test", all_cond, 1);
   psi->register_file("test", all_file, 1);
+  psi->register_socket("test", all_socket, 1);
   psi->register_thread("test", all_thread, 1);
 
   PFS_mutex_class *mutex_class_A;
   PFS_rwlock_class *rwlock_class_A;
   PFS_cond_class *cond_class_A;
   PFS_file_class *file_class_A;
+  PFS_socket_class *socket_class_A;
   PSI_mutex *mutex_A1;
   PSI_rwlock *rwlock_A1;
   PSI_cond *cond_A1;
   PSI_file *file_A1;
+  PSI_socket *socket_A1;
   PSI_thread *thread_1;
 
   /* Preparation */
@@ -924,6 +1076,9 @@ void test_locker_disabled()
   file_class_A= find_file_class(file_key_A);
   ok(file_class_A != NULL, "file info A");
 
+  socket_class_A= find_socket_class(socket_key_A);
+  ok(socket_class_A != NULL, "socket info A");
+
   /* Pretend thread T-1 is running, and enabled */
   /* ------------------------------------------ */
 
@@ -949,6 +1104,10 @@ void test_locker_disabled()
   file_A1= (PSI_file*) lookup_file_by_name("foo");
   ok(file_A1 != NULL, "instrumented");
 
+  socket_class_A->m_enabled= true;
+  socket_A1= psi->init_socket(socket_key_A, NULL);
+  ok(socket_A1 != NULL, "instrumented");
+
   PSI_mutex_locker *mutex_locker;
   PSI_mutex_locker_state mutex_state;
   PSI_rwlock_locker *rwlock_locker;
@@ -957,6 +1116,8 @@ void test_locker_disabled()
   PSI_cond_locker_state cond_state;
   PSI_file_locker *file_locker;
   PSI_file_locker_state file_state;
+  PSI_socket_locker *socket_locker;
+  PSI_socket_locker_state socket_state;
 
   /* Pretend thread T-1 is disabled */
   /* ------------------------------ */
@@ -967,7 +1128,7 @@ void test_locker_disabled()
   rwlock_class_A->m_enabled= true;
   cond_class_A->m_enabled= true;
   file_class_A->m_enabled= true;
-
+  socket_class_A->m_enabled= true;
 
   mutex_locker= psi->get_thread_mutex_locker(&mutex_state, mutex_A1, PSI_MUTEX_LOCK);
   ok(mutex_locker == NULL, "no locker (T-1 disabled)");
@@ -981,6 +1142,8 @@ void test_locker_disabled()
   ok(file_locker == NULL, "no locker (T-1 disabled)");
   file_locker= psi->get_thread_file_descriptor_locker(&file_state, (File) 12, PSI_FILE_READ);
   ok(file_locker == NULL, "no locker (T-1 disabled)");
+  socket_locker= psi->get_thread_socket_locker(&socket_state, socket_A1, PSI_SOCKET_SEND);
+  ok(socket_locker == NULL, "no locker (T-1 disabled)");
 
   /* Pretend the global consumer is disabled */
   /* --------------------------------------- */
@@ -991,6 +1154,7 @@ void test_locker_disabled()
   rwlock_class_A->m_enabled= true;
   cond_class_A->m_enabled= true;
   file_class_A->m_enabled= true;
+  socket_class_A->m_enabled= true;
 
   mutex_locker= psi->get_thread_mutex_locker(&mutex_state, mutex_A1, PSI_MUTEX_LOCK);
   ok(mutex_locker == NULL, "no locker (global disabled)");
@@ -1004,6 +1168,8 @@ void test_locker_disabled()
   ok(file_locker == NULL, "no locker (global disabled)");
   file_locker= psi->get_thread_file_descriptor_locker(&file_state, (File) 12, PSI_FILE_READ);
   ok(file_locker == NULL, "no locker (global disabled)");
+  socket_locker= psi->get_thread_socket_locker(&socket_state, socket_A1, PSI_SOCKET_SEND);
+  ok(socket_locker == NULL, "no locker (global disabled)");
 
   /* Pretent the mode is global, counted only */
   /* ---------------------------------------- */
@@ -1019,6 +1185,8 @@ void test_locker_disabled()
   cond_class_A->m_timed= false;
   file_class_A->m_enabled= true;
   file_class_A->m_timed= false;
+  socket_class_A->m_enabled= true;
+  socket_class_A->m_timed= false;
 
   mutex_locker= psi->get_thread_mutex_locker(&mutex_state, mutex_A1, PSI_MUTEX_LOCK);
   ok(mutex_locker == NULL, "no locker (global counted)");
@@ -1038,6 +1206,8 @@ void test_locker_disabled()
   ok(file_locker != NULL, "locker (global counted)");
   psi->start_file_wait(file_locker, 10, __FILE__, __LINE__);
   psi->end_file_wait(file_locker, 10);
+  socket_locker= psi->get_thread_socket_locker(&socket_state, socket_A1, PSI_SOCKET_SEND);
+  ok(socket_locker == NULL, "no locker (global counted)");
 
   /* TODO */
 
@@ -1051,6 +1221,7 @@ void test_locker_disabled()
   rwlock_class_A->m_enabled= false;
   cond_class_A->m_enabled= false;
   file_class_A->m_enabled= false;
+  socket_class_A->m_enabled= false;
 
   mutex_locker= psi->get_thread_mutex_locker(&mutex_state, mutex_A1, PSI_MUTEX_LOCK);
   ok(mutex_locker == NULL, "no locker");
@@ -1064,6 +1235,8 @@ void test_locker_disabled()
   ok(file_locker == NULL, "no locker");
   file_locker= psi->get_thread_file_descriptor_locker(&file_state, (File) 12, PSI_FILE_READ);
   ok(file_locker == NULL, "no locker");
+  socket_locker= psi->get_thread_socket_locker(&socket_state, socket_A1, PSI_SOCKET_SEND);
+  ok(socket_locker == NULL, "no locker");
 
   /* Pretend everything is enabled and timed */
   /* --------------------------------------- */
@@ -1080,6 +1253,8 @@ void test_locker_disabled()
   cond_class_A->m_timed= true;
   file_class_A->m_enabled= true;
   file_class_A->m_timed= true;
+  socket_class_A->m_enabled= true;
+  socket_class_A->m_timed= true;
 
   mutex_locker= psi->get_thread_mutex_locker(&mutex_state, mutex_A1, PSI_MUTEX_LOCK);
   ok(mutex_locker != NULL, "locker");
@@ -1105,6 +1280,10 @@ void test_locker_disabled()
   ok(file_locker != NULL, "locker");
   psi->start_file_wait(file_locker, 10, __FILE__, __LINE__);
   psi->end_file_wait(file_locker, 10);
+  socket_locker= psi->get_thread_socket_locker(&socket_state, socket_A1, PSI_SOCKET_SEND);
+  ok(socket_locker != NULL, "locker");
+  psi->start_socket_wait(socket_locker, 10, __FILE__, __LINE__);
+  psi->end_socket_wait(socket_locker, 10);
 
   /* Pretend the running thread is not instrumented */
   /* ---------------------------------------------- */
@@ -1115,6 +1294,7 @@ void test_locker_disabled()
   rwlock_class_A->m_enabled= true;
   cond_class_A->m_enabled= true;
   file_class_A->m_enabled= true;
+  socket_class_A->m_enabled= true;
 
   mutex_locker= psi->get_thread_mutex_locker(&mutex_state, mutex_A1, PSI_MUTEX_LOCK);
   ok(mutex_locker == NULL, "no locker");
@@ -1128,6 +1308,8 @@ void test_locker_disabled()
   ok(file_locker == NULL, "no locker");
   file_locker= psi->get_thread_file_descriptor_locker(&file_state, (File) 12, PSI_FILE_READ);
   ok(file_locker == NULL, "no locker");
+  socket_locker= psi->get_thread_socket_locker(&socket_state, socket_A1, PSI_SOCKET_SEND);
+  ok(socket_locker == NULL, "no locker");
 
   shutdown_performance_schema();
 }
@@ -1274,8 +1456,10 @@ void test_event_name_index()
   param.m_cond_class_sizing= 40;
   /* Per file info waits should be at [70..149] */
   param.m_file_class_sizing= 80;
-  /* Per table info waits should be at [150] */
-  param.m_table_share_sizing= 160;
+  /* Per socket info waits should be at [150..309] */
+  param.m_socket_class_sizing= 160;
+  /* Per table info waits should be at [310] */
+  param.m_table_share_sizing= 320;
 
   param.m_thread_class_sizing= 0;
 
@@ -1286,6 +1470,7 @@ void test_event_name_index()
   param.m_table_sizing= 0;
   param.m_file_sizing= 0;
   param.m_file_handle_sizing= 0;
+  param.m_socket_sizing= 0;
   param.m_events_waits_history_sizing= 0;
   param.m_events_waits_history_long_sizing= 0;
   param.m_setup_actor_sizing= 0;
@@ -1364,8 +1549,25 @@ void test_event_name_index()
   ok(file_class != NULL, "file class 2");
   ok(file_class->m_event_name_index == 71, "index 71");
 
-  ok(global_table_io_class.m_event_name_index == 150, "index 150");
-  ok(max_instrument_class= 151, "151 event names");
+  PFS_socket_class *socket_class;
+  PSI_socket_key dummy_socket_key_1;
+  PSI_socket_key dummy_socket_key_2;
+  PSI_socket_info dummy_sockets[]=
+  {
+    { & dummy_socket_key_1, "S-1", 0},
+    { & dummy_socket_key_2, "S-2", 0}
+  };
+
+  psi->register_socket("X", dummy_sockets, 2);
+  socket_class= find_socket_class(dummy_socket_key_1);
+  ok(socket_class != NULL, "socket class 1");
+  ok(socket_class->m_event_name_index == 150, "index 150");
+  socket_class= find_socket_class(dummy_socket_key_2);
+  ok(socket_class != NULL, "socket class 2");
+  ok(socket_class->m_event_name_index == 151, "index 151");
+
+  ok(global_table_io_class.m_event_name_index == 310, "index 310");
+  ok(max_instrument_class= 313, "313 event names"); // 3 global classes
 }
 
 void do_all_tests()

=== modified file 'storage/perfschema/unittest/pfs_instr-oom-t.cc'
--- a/storage/perfschema/unittest/pfs_instr-oom-t.cc	2011-03-08 17:24:34 +0000
+++ b/storage/perfschema/unittest/pfs_instr-oom-t.cc	2011-03-21 02:01:31 +0000
@@ -38,6 +38,7 @@ void test_oom()
   param.m_thread_class_sizing= 0;
   param.m_table_share_sizing= 0;
   param.m_file_class_sizing= 0;
+  param.m_socket_class_sizing= 0;
   param.m_mutex_sizing= 1000;
   param.m_rwlock_sizing= 0;
   param.m_cond_sizing= 0;
@@ -45,6 +46,7 @@ void test_oom()
   param.m_table_sizing= 0;
   param.m_file_sizing= 0;
   param.m_file_handle_sizing= 0;
+  param.m_socket_sizing= 0;
   param.m_events_waits_history_sizing= 0;
   param.m_events_waits_history_long_sizing= 0;
   param.m_setup_actor_sizing= 0;
@@ -61,6 +63,7 @@ void test_oom()
   param.m_thread_class_sizing= 0;
   param.m_table_share_sizing= 0;
   param.m_file_class_sizing= 0;
+  param.m_socket_class_sizing= 0;
   param.m_mutex_sizing= 0;
   param.m_rwlock_sizing= 1000;
   param.m_cond_sizing= 0;
@@ -68,6 +71,7 @@ void test_oom()
   param.m_table_sizing= 0;
   param.m_file_sizing= 0;
   param.m_file_handle_sizing= 0;
+  param.m_socket_sizing= 0;
   param.m_events_waits_history_sizing= 0;
   param.m_events_waits_history_long_sizing= 0;
   param.m_setup_actor_sizing= 0;
@@ -84,6 +88,7 @@ void test_oom()
   param.m_thread_class_sizing= 0;
   param.m_table_share_sizing= 0;
   param.m_file_class_sizing= 0;
+  param.m_socket_class_sizing= 0;
   param.m_mutex_sizing= 0;
   param.m_rwlock_sizing= 0;
   param.m_cond_sizing= 1000;
@@ -91,6 +96,7 @@ void test_oom()
   param.m_table_sizing= 0;
   param.m_file_sizing= 0;
   param.m_file_handle_sizing= 0;
+  param.m_socket_sizing= 0;
   param.m_events_waits_history_sizing= 0;
   param.m_events_waits_history_long_sizing= 0;
   param.m_setup_actor_sizing= 0;
@@ -107,6 +113,7 @@ void test_oom()
   param.m_thread_class_sizing= 0;
   param.m_table_share_sizing= 0;
   param.m_file_class_sizing= 10;
+  param.m_socket_class_sizing= 0;
   param.m_mutex_sizing= 0;
   param.m_rwlock_sizing= 0;
   param.m_cond_sizing= 0;
@@ -114,6 +121,7 @@ void test_oom()
   param.m_table_sizing= 0;
   param.m_file_sizing= 1000;
   param.m_file_handle_sizing= 1000;
+  param.m_socket_sizing= 0;
   param.m_events_waits_history_sizing= 0;
   param.m_events_waits_history_long_sizing= 0;
   param.m_setup_actor_sizing= 0;
@@ -130,6 +138,7 @@ void test_oom()
   param.m_thread_class_sizing= 0;
   param.m_table_share_sizing= 10;
   param.m_file_class_sizing= 0;
+  param.m_socket_class_sizing= 0;
   param.m_mutex_sizing= 0;
   param.m_rwlock_sizing= 0;
   param.m_cond_sizing= 0;
@@ -137,6 +146,7 @@ void test_oom()
   param.m_table_sizing= 1000;
   param.m_file_sizing= 0;
   param.m_file_handle_sizing= 0;
+  param.m_socket_sizing= 0;
   param.m_events_waits_history_sizing= 0;
   param.m_events_waits_history_long_sizing= 0;
   param.m_setup_actor_sizing= 0;
@@ -153,6 +163,7 @@ void test_oom()
   param.m_thread_class_sizing= 10;
   param.m_table_share_sizing= 0;
   param.m_file_class_sizing= 0;
+  param.m_socket_class_sizing= 0;
   param.m_mutex_sizing= 0;
   param.m_rwlock_sizing= 0;
   param.m_cond_sizing= 0;
@@ -160,6 +171,7 @@ void test_oom()
   param.m_table_sizing= 0;
   param.m_file_sizing= 0;
   param.m_file_handle_sizing= 0;
+  param.m_socket_sizing= 0;
   param.m_events_waits_history_sizing= 0;
   param.m_events_waits_history_long_sizing= 0;
   param.m_setup_actor_sizing= 0;
@@ -178,6 +190,7 @@ void test_oom()
   param.m_thread_class_sizing= 10;
   param.m_table_share_sizing= 0;
   param.m_file_class_sizing= 0;
+  param.m_socket_class_sizing= 0;
   param.m_mutex_sizing= 0;
   param.m_rwlock_sizing= 0;
   param.m_cond_sizing= 0;
@@ -185,6 +198,7 @@ void test_oom()
   param.m_table_sizing= 0;
   param.m_file_sizing= 0;
   param.m_file_handle_sizing= 0;
+  param.m_socket_sizing= 0;
   param.m_events_waits_history_sizing= 10;
   param.m_events_waits_history_long_sizing= 0;
   param.m_setup_actor_sizing= 0;
@@ -202,6 +216,7 @@ void test_oom()
   param.m_thread_class_sizing= 10;
   param.m_table_share_sizing= 0;
   param.m_file_class_sizing= 50;
+  param.m_socket_class_sizing= 0;
   param.m_mutex_sizing= 0;
   param.m_rwlock_sizing= 0;
   param.m_cond_sizing= 0;
@@ -209,6 +224,7 @@ void test_oom()
   param.m_table_sizing= 0;
   param.m_file_sizing= 0;
   param.m_file_handle_sizing= 0;
+  param.m_socket_sizing= 0;
   param.m_events_waits_history_sizing= 0;
   param.m_events_waits_history_long_sizing= 0;
   param.m_setup_actor_sizing= 0;
@@ -219,6 +235,31 @@ void test_oom()
   rc= init_instruments(& param);
   ok(rc == 1, "oom (per thread wait)");
 
+  param.m_enabled= true;
+  param.m_mutex_class_sizing= 0;
+  param.m_rwlock_class_sizing= 0;
+  param.m_cond_class_sizing= 0;
+  param.m_thread_class_sizing= 0;
+  param.m_table_share_sizing= 0;
+  param.m_file_class_sizing= 0;
+  param.m_socket_class_sizing= 10;
+  param.m_mutex_sizing= 0;
+  param.m_rwlock_sizing= 0;
+  param.m_cond_sizing= 0;
+  param.m_thread_sizing= 0;
+  param.m_table_sizing= 0;
+  param.m_file_sizing= 0;
+  param.m_file_handle_sizing= 0;
+  param.m_socket_sizing= 1000;
+  param.m_events_waits_history_sizing= 0;
+  param.m_events_waits_history_long_sizing= 0;
+  param.m_setup_actor_sizing= 0;
+  param.m_setup_object_sizing= 0;
+
+  init_event_name_sizing(& param);
+  rc= init_instruments(& param);
+  ok(rc == 1, "oom (socket)");
+
   cleanup_instruments();
 }
 

=== modified file 'storage/perfschema/unittest/pfs_instr-t.cc'
--- a/storage/perfschema/unittest/pfs_instr-t.cc	2011-03-08 17:24:34 +0000
+++ b/storage/perfschema/unittest/pfs_instr-t.cc	2011-03-21 02:01:31 +0000
@@ -37,6 +37,7 @@ void test_no_instruments()
   param.m_thread_class_sizing= 0;
   param.m_table_share_sizing= 0;
   param.m_file_class_sizing= 0;
+  param.m_socket_class_sizing= 0;
   param.m_mutex_sizing= 0;
   param.m_rwlock_sizing= 0;
   param.m_cond_sizing= 0;
@@ -44,6 +45,7 @@ void test_no_instruments()
   param.m_table_sizing= 0;
   param.m_file_sizing= 0;
   param.m_file_handle_sizing= 0;
+  param.m_socket_sizing= 0;
   param.m_events_waits_history_sizing= 0;
   param.m_events_waits_history_long_sizing= 0;
   param.m_setup_actor_sizing= 0;
@@ -65,11 +67,13 @@ void test_no_instances()
   PFS_thread_class dummy_thread_class;
   PFS_file_class dummy_file_class;
   PFS_table_share dummy_table_share;
+  PFS_socket_class dummy_socket_class;
   PFS_mutex *mutex;
   PFS_rwlock *rwlock;
   PFS_cond *cond;
   PFS_thread *thread;
   PFS_file *file;
+  PFS_socket *socket;
   PFS_table *table;
   PFS_global_param param;
 
@@ -80,6 +84,7 @@ void test_no_instances()
   param.m_thread_class_sizing= 1;
   param.m_table_share_sizing= 1;
   param.m_file_class_sizing= 1;
+  param.m_socket_class_sizing= 0;
   param.m_mutex_sizing= 0;
   param.m_rwlock_sizing= 0;
   param.m_cond_sizing= 0;
@@ -87,6 +92,7 @@ void test_no_instances()
   param.m_table_sizing= 0;
   param.m_file_sizing= 0;
   param.m_file_handle_sizing= 0;
+  param.m_socket_sizing= 0;
   param.m_events_waits_history_sizing= 0;
   param.m_events_waits_history_long_sizing= 0;
   param.m_setup_actor_sizing= 0;
@@ -158,6 +164,13 @@ void test_no_instances()
   ok(table == NULL, "no table");
   ok(table_lost == 2, "lost 2");
 
+  socket= create_socket(& dummy_socket_class, NULL);
+  ok(socket == NULL, "no socket");
+  ok(socket_lost == 1, "lost 1");
+  socket= create_socket(& dummy_socket_class, NULL);
+  ok(socket == NULL, "no socket");
+  ok(socket_lost == 2, "lost 2");
+
   /* No result to test, just make sure it does not crash */
   reset_events_waits_by_instance();
   reset_per_thread_wait_stat();
@@ -174,6 +187,7 @@ void test_with_instances()
   PFS_cond_class dummy_cond_class;
   PFS_thread_class dummy_thread_class;
   PFS_file_class dummy_file_class;
+  PFS_socket_class dummy_socket_class;
   PFS_table_share dummy_table_share;
   PFS_mutex *mutex_1;
   PFS_mutex *mutex_2;
@@ -185,6 +199,8 @@ void test_with_instances()
   PFS_thread *thread_2;
   PFS_file *file_1;
   PFS_file *file_2;
+  PFS_socket *socket_1;
+  PFS_socket *socket_2;
   PFS_table *table_1;
   PFS_table *table_2;
   PFS_global_param param;
@@ -196,6 +212,7 @@ void test_with_instances()
   param.m_thread_class_sizing= 1;
   param.m_table_share_sizing= 1;
   param.m_file_class_sizing= 1;
+  param.m_socket_class_sizing= 1;
   param.m_mutex_sizing= 2;
   param.m_rwlock_sizing= 2;
   param.m_cond_sizing= 2;
@@ -203,6 +220,7 @@ void test_with_instances()
   param.m_table_sizing= 2;
   param.m_file_sizing= 2;
   param.m_file_handle_sizing= 100;
+  param.m_socket_sizing= 2;
   param.m_events_waits_history_sizing= 10;
   param.m_events_waits_history_long_sizing= 10000;
   param.m_setup_actor_sizing= 0;
@@ -216,6 +234,7 @@ void test_with_instances()
   dummy_rwlock_class.m_event_name_index= 1;
   dummy_cond_class.m_event_name_index= 2;
   dummy_file_class.m_event_name_index= 3;
+  dummy_socket_class.m_event_name_index= 4;
 
   mutex_1= create_mutex(& dummy_mutex_class, NULL);
   ok(mutex_1 != NULL, "mutex");
@@ -309,6 +328,20 @@ void test_with_instances()
   ok(file_2 == NULL, "no file");
   ok(file_lost == 2, "lost");
 
+  socket_1= create_socket(& dummy_socket_class, NULL);
+  ok(socket_1 != NULL, "socket");
+  ok(socket_lost == 0, "not lost");
+  socket_2= create_socket(& dummy_socket_class, NULL);
+  ok(socket_2 != NULL, "socket");
+  ok(socket_lost == 0, "not lost");
+  socket_2= create_socket(& dummy_socket_class, NULL);
+  ok(socket_2 == NULL, "no socket");
+  ok(socket_lost == 1, "lost 1");
+  destroy_socket(socket_1);
+  socket_2= create_socket(& dummy_socket_class, NULL);
+  ok(socket_2 != NULL, "socket");
+  ok(socket_lost == 1, "no new loss");
+
   table_1= create_table(& dummy_table_share, & fake_thread, NULL);
   ok(table_1 != NULL, "table");
   ok(table_lost == 0, "not lost");

=== modified file 'storage/perfschema/unittest/pfs_instr_class-oom-t.cc'
--- a/storage/perfschema/unittest/pfs_instr_class-oom-t.cc	2011-03-08 17:24:34 +0000
+++ b/storage/perfschema/unittest/pfs_instr_class-oom-t.cc	2011-03-21 02:01:31 +0000
@@ -38,11 +38,14 @@ void test_oom()
   ok(rc == 1, "oom (file)");
   rc= init_table_share(1000);
   ok(rc == 1, "oom (cond)");
+  rc= init_socket_class(1000);
+  ok(rc == 1, "oom (socket)");
 
   cleanup_sync_class();
   cleanup_thread_class();
   cleanup_file_class();
   cleanup_table_share();
+  cleanup_socket_class();
 }
 
 void do_all_tests()

=== modified file 'storage/perfschema/unittest/pfs_instr_class-t.cc'
--- a/storage/perfschema/unittest/pfs_instr_class-t.cc	2011-03-08 17:24:34 +0000
+++ b/storage/perfschema/unittest/pfs_instr_class-t.cc	2011-03-21 02:01:31 +0000
@@ -29,11 +29,13 @@ void test_no_registration()
   PFS_sync_key key;
   PFS_thread_key thread_key;
   PFS_file_key file_key;
+  PFS_socket_key socket_key;
   PFS_mutex_class *mutex;
   PFS_rwlock_class *rwlock;
   PFS_cond_class *cond;
   PFS_thread_class *thread;
   PFS_file_class *file;
+  PFS_socket_class *socket;
   /* PFS_table_share *table; */
 
   rc= init_sync_class(0, 0, 0);
@@ -42,6 +44,8 @@ void test_no_registration()
   ok(rc == 0, "zero init (thread)");
   rc= init_file_class(0);
   ok(rc == 0, "zero init (file)");
+  rc= init_socket_class(0);
+  ok(rc == 0, "zero init (socket)");
   rc= init_table_share(0);
   ok(rc == 0, "zero init (table)");
 
@@ -80,6 +84,13 @@ void test_no_registration()
   file_key= register_file_class("FOO", 3, 0);
   ok(file_key == 0, "no file registered");
 
+  socket_key= register_socket_class("FOO", 3, 0);
+  ok(socket_key == 0, "no socket registered");
+  socket_key= register_socket_class("BAR", 3, 0);
+  ok(socket_key == 0, "no socket registered");
+  socket_key= register_socket_class("FOO", 3, 0);
+  ok(socket_key == 0, "no socket registered");
+
   PFS_thread fake_thread;
   fake_thread.m_table_share_hash_pins= NULL;
 
@@ -127,9 +138,17 @@ void test_no_registration()
   file= find_file_class(9999);
   ok(file == NULL, "no file key 9999");
 
+  socket= find_socket_class(0);
+  ok(socket == NULL, "no socket key 0");
+  socket= find_socket_class(1);
+  ok(socket == NULL, "no socket key 1");
+  socket= find_socket_class(9999);
+  ok(socket == NULL, "no socket key 9999");
+
   cleanup_sync_class();
   cleanup_thread_class();
   cleanup_file_class();
+  cleanup_socket_class();
   cleanup_table_share();
 }
 
@@ -348,6 +367,53 @@ void test_file_registration()
   cleanup_file_class();
 }
 
+void test_socket_registration()
+{
+  int rc;
+  PFS_socket_key key;
+  PFS_socket_class *socket;
+
+  rc= init_socket_class(5);
+  ok(rc == 0, "room for 5 socket");
+
+  key= register_socket_class("FOO", 3, 0);
+  ok(key == 1, "foo registered");
+  key= register_socket_class("BAR", 3, 0);
+  ok(key == 2, "bar registered");
+  key= register_socket_class("FOO", 3, 0);
+  ok(key == 1, "foo re registered");
+  key= register_socket_class("Socket-3", 8, 0);
+  ok(key == 3, "Socket-3 registered");
+  key= register_socket_class("Socket-4", 8, 0);
+  ok(key == 4, "Socket-4 registered");
+  key= register_socket_class("Socket-5", 8, 0);
+  ok(key == 5, "Socket-5 registered");
+  ok(socket_class_lost == 0, "lost nothing");
+  key= register_socket_class("Socket-6", 8, 0);
+  ok(key == 0, "Socket-6 not registered");
+  ok(socket_class_lost == 1, "lost 1 socket");
+  key= register_socket_class("Socket-7", 8, 0);
+  ok(key == 0, "Socket-7 not registered");
+  ok(socket_class_lost == 2, "lost 2 socket");
+  key= register_socket_class("Socket-3", 8, 0);
+  ok(key == 3, "Socket-3 re registered");
+  ok(socket_class_lost == 2, "lost 2 socket");
+  key= register_socket_class("Socket-5", 8, 0);
+  ok(key == 5, "Socket-5 re registered");
+  ok(socket_class_lost == 2, "lost 2 socket");
+
+  socket= find_socket_class(0);
+  ok(socket == NULL, "no key 0");
+  socket= find_socket_class(3);
+  ok(socket != NULL, "found key 3");
+  ok(strncmp(socket->m_name, "Socket-3", 8) == 0, "key 3 is Socket-3");
+  ok(socket->m_name_length == 8, "name length 3");
+  socket= find_socket_class(9999);
+  ok(socket == NULL, "no key 9999");
+
+  cleanup_socket_class();
+}
+
 void test_table_registration()
 {
 #ifdef LATER
@@ -441,6 +507,7 @@ void test_instruments_reset()
   int rc;
   PFS_sync_key key;
   PFS_file_key file_key;
+  PFS_socket_key socket_key;
   PFS_mutex_class *mutex_1;
   PFS_mutex_class *mutex_2;
   PFS_mutex_class *mutex_3;
@@ -453,6 +520,9 @@ void test_instruments_reset()
   PFS_file_class *file_1;
   PFS_file_class *file_2;
   PFS_file_class *file_3;
+  PFS_socket_class *socket_1;
+  PFS_socket_class *socket_2;
+  PFS_socket_class *socket_3;
 
   rc= init_sync_class(3, 3, 3);
   ok(rc == 0, "init (sync)");
@@ -460,6 +530,8 @@ void test_instruments_reset()
   ok(rc == 0, "init (thread)");
   rc= init_file_class(3);
   ok(rc == 0, "init (file)");
+  rc= init_socket_class(3);
+  ok(rc == 0, "init (socket)");
 
   key= register_mutex_class("M-1", 3, 0);
   ok(key == 1, "mutex registered");
@@ -489,6 +561,13 @@ void test_instruments_reset()
   file_key= register_file_class("F-3", 3, 0);
   ok(file_key == 3, "file registered");
 
+  socket_key= register_socket_class("S-1", 3, 0);
+  ok(socket_key == 1, "socket registered");
+  socket_key= register_socket_class("S-2", 3, 0);
+  ok(socket_key == 2, "socket registered");
+  socket_key= register_socket_class("S-3", 3, 0);
+  ok(socket_key == 3, "socket registered");
+
   mutex_1= find_mutex_class(1);
   ok(mutex_1 != NULL, "mutex key 1");
   mutex_2= find_mutex_class(2);
@@ -517,6 +596,13 @@ void test_instruments_reset()
   file_3= find_file_class(3);
   ok(file_3 != NULL, "file key 3");
 
+  socket_1= find_socket_class(1);
+  ok(socket_1 != NULL, "socket key 1");
+  socket_2= find_socket_class(2);
+  ok(socket_2 != NULL, "socket key 2");
+  socket_3= find_socket_class(3);
+  ok(socket_3 != NULL, "socket key 3");
+
 #ifdef LATER
   set_wait_stat(mutex_1);
   set_wait_stat(mutex_2);
@@ -562,6 +648,7 @@ void test_instruments_reset()
 
   cleanup_sync_class();
   cleanup_file_class();
+  cleanup_socket_class();
 }
 
 void do_all_tests()
@@ -574,6 +661,7 @@ void do_all_tests()
   test_cond_registration();
   test_thread_registration();
   test_file_registration();
+  test_socket_registration();
   test_table_registration();
   test_instruments_reset();
 


Attachment: [text/bzr-bundle] bzr/cpowers@tma-1-20110321020528-xu0od846oak5aoem.bundle
Thread
bzr push into mysql-trunk branch (chris.powers:3269) Christopher Powers21 Mar