List:Commits« Previous MessageNext Message »
From:Mikael Ronstrom Date:December 12 2009 10:08am
Subject:bzr commit into mysql-5.6-next-mr branch (mikael:2948)
View as plain text  
#At file:///home/mikael/mysql_clones/mysql-next-mr-wl5136/ based on revid:mikael@stripped

 2948 Mikael Ronstrom	2009-12-12
      More editorials

    modified:
      sql/scheduler_poll.cc
=== modified file 'sql/scheduler_poll.cc'
--- a/sql/scheduler_poll.cc	2009-12-12 10:06:50 +0000
+++ b/sql/scheduler_poll.cc	2009-12-12 10:07:58 +0000
@@ -78,7 +78,7 @@ typedef struct _tp_cln_low_level_s
   int                   wait_type;
 } poll_client_context_t;
 
-static int tp_cln_low_level_dis_arm(tp_cln_low_level_t tp_cln_low_level_cntx);
+static void tp_cln_low_level_disarm(tp_cln_low_level_t tp_cln_low_level_cntx);
 
 /*********************************************************************/
 /* Global Variables */
@@ -160,8 +160,8 @@ static int waiter_wake(tp_grp_low_level_
   char msg[1];
 
   /* Write a byte to wake up the waiter thread */
-  return write(tp_grp_low_level_cntx->array[TP_POLL_NOTIFY_FD_INDEX].fd,
-               msg, 1);
+  return (write(tp_grp_low_level_cntx->array[TP_POLL_NOTIFY_FD_INDEX].fd,
+                msg, 1) == 1) ? FALSE : TRUE;
 }
 
 /*********************************************************************/
@@ -215,8 +215,7 @@ static int tp_grp_low_level_wait_for_eve
     }
 
     /* Clean up all client errors */
-    for (client_count= 0; client_count < MAX_THREADS_PER_GROUP;
-          client_count++)
+    for (client_count= 0; client_count < clients_valid; client_count++)
     {
       client_index= client_count + TP_FIRST_REAL_FD;
 
@@ -231,7 +230,7 @@ static int tp_grp_low_level_wait_for_eve
               tp_grp_low_level_cntx->low_level_cntx[client_index];
 
         /* Process the event */
-        tp_cln_low_level_dis_arm(my_thread_data->client_low_level_cntx);
+        tp_cln_low_level_disarm(my_thread_data->client_low_level_cntx);
         tp_process_event(my_thread_data);
         my_thread_data->client_low_level_cntx= NULL;
         tp_grp_low_level_cntx->array[client_index].fd= 0;
@@ -250,9 +249,9 @@ static int tp_grp_low_level_wait_for_eve
     if (events_total <= 0)
       continue;
 
-    if (events_total == 1) {
-      for (client_count= 0; client_count < MAX_THREADS_PER_GROUP;
-           client_count++)
+    if (events_total == 1)
+    {
+      for (client_count= 0; client_count < clients_valid; client_count++)
       {
         client_index= (tp_grp_low_level_cntx->last_check &
                               MAX_THREADS_PER_GROUP_MASK) + TP_FIRST_REAL_FD;
@@ -267,7 +266,7 @@ static int tp_grp_low_level_wait_for_eve
                 tp_grp_low_level_cntx->low_level_cntx[client_index];
 
           /* Process the event */
-          tp_cln_low_level_dis_arm(my_thread_data->client_low_level_cntx);
+          tp_cln_low_level_disarm(my_thread_data->client_low_level_cntx);
           tp_process_event(my_thread_data);
           my_thread_data->client_low_level_cntx= NULL;
           events_total= 0;
@@ -276,24 +275,24 @@ static int tp_grp_low_level_wait_for_eve
         tp_grp_low_level_cntx->last_check++;
 
       }
-    } else {
+    }
+    else
+    {
       if (events_total > 1)
       {
         /*
           Put all clients that are ready into the "ready" list
           start at 2 as first 2 sockets are special internal only
-          Where 2 is in TP_FIRST_REAL_FD
         */
 
-        for (client_count= 0; client_count < MAX_THREADS_PER_GROUP;
-              client_count++)
+        for (client_count= 0; client_count < clients_valid; client_count++)
         {
           client_index= (tp_grp_low_level_cntx->last_check &
                                 MAX_THREADS_PER_GROUP_MASK) + TP_FIRST_REAL_FD;
           tp_grp_low_level_cntx->last_check++;
           if (tp_grp_low_level_cntx->array[client_index].revents != 0)
           {
-            tp_cln_low_level_dis_arm(
+            tp_cln_low_level_disarm(
                     tp_grp_low_level_cntx->low_level_cntx[client_index]);
             next_events->event_ready_array[events_copied]=
                      tp_grp_low_level_cntx->low_level_cntx[client_index];
@@ -355,10 +354,11 @@ static tp_cln_low_level_t tp_cln_low_lev
   struct pollfd *poll_cln;
 
   /*
-    Start at 2 as first 2 sockets are special internal only (2 in TP_FIRST_REAL_FD).
+    Start at 2 as first 2 sockets are special internal only.
   */
   for (client_index= TP_FIRST_REAL_FD; client_index < TP_POLL_MAX_FDS; client_index++)
   {
+    /* Find first non-used client index */
     if (tp_grp_low_level_cntx->array[client_index].fd == 0)
     {
       tp_cln_low_level_cntx= (tp_cln_low_level_t) my_malloc(
@@ -401,9 +401,9 @@ static int tp_cln_low_level_arm(tp_cln_l
   poll_cln->events= TP_POLL_WAIT_EVENTS;
   poll_cln->revents= 0;
 
-  if (waiter_wake(tp_cln_low_level_cntx->group) != 1)
+  if (waiter_wake(tp_cln_low_level_cntx->group))
   {
-    sql_print_error("epoll_ctl(...,EPOLL_CTL_ADD) failed: error %d", errno);
+    sql_print_error("poll arm failed: error %d", errno);
     return 1;
   }
   return 0;
@@ -416,7 +416,7 @@ static int tp_cln_low_level_rearm(tp_cln
 }
 
 /*********************************************************************/
-static int tp_cln_low_level_dis_arm(tp_cln_low_level_t tp_cln_low_level_cntx)
+static void tp_cln_low_level_disarm(tp_cln_low_level_t tp_cln_low_level_cntx)
 {
   int client_index;
   struct pollfd       *poll_cln;
@@ -426,8 +426,6 @@ static int tp_cln_low_level_dis_arm(tp_c
 
   poll_cln->events= 0;
   poll_cln->revents= 0;
-
-  return 0;
 }
 
 /*********************************************************************/
@@ -464,7 +462,6 @@ static void tp_cln_low_level_set_wait_ty
         int wait_type)
 {
   tp_cln_low_level_cntx->wait_type= wait_type;
-  return;
 }
 
 /*********************************************************************/
@@ -478,7 +475,7 @@ static int tp_cln_low_level_end(tp_cln_l
     client_index= tp_cln_low_level_cntx->index;
     group= tp_cln_low_level_cntx->group;
 
-    tp_cln_low_level_dis_arm(tp_cln_low_level_cntx);
+    tp_cln_low_level_disarm(tp_cln_low_level_cntx);
 
     /* position memory */
     tp_cln_low_level_cntx->thd= NULL;


Attachment: [text/bzr-bundle] bzr/mikael@mysql.com-20091212100758-5nk2mvci13cv8mxt.bundle
Thread
bzr commit into mysql-5.6-next-mr branch (mikael:2948) Mikael Ronstrom12 Dec