MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Dmitry Shulga Date:July 5 2010 10:16am
Subject:bzr commit into mysql-5.1-bugteam branch (Dmitry.Shulga:3454) Bug#42496
View as plain text  
#At file:///Users/shulga/projects/mysql/5.1-bugteam-bug42496/ based on revid:dmitry.shulga@stripped

 3454 Dmitry Shulga	2010-07-05
      Fixed bug #42496 - the server could crash on a debug assert after a failure
      to write into a closed socket
     @ sql/protocol.cc
        Protocol::flush modified: set thd->main_da.can_overwrite_status= TRUE
        before call to net_flush() in order to prevent crash on assert in case
        of socket write failure, reset it to FALSE when net_flush() returned;
        Protocol::send_fields modified: return from method with error if call to
        my_net_write(), proto.write() or write_eof_packet() failed.
     @ sql/sql_cache.cc
        Query_cache::send_result_to_client modified: set
        thd->main_da.can_overwrite_status= TRUE before call to write
        data to socket and reset it to FALSE when write completed
        (successfully or failure).
     @ sql/sql_cursor.cc
        Materialized_cursor::fetch modified: leave method if call to
        result->send_data() failed.
     @ sql/sql_prepare.cc
        send_prep_stmt() modified: call to thd->main_da.disable_status()
        only if thd->protocol_text.send_fields() completed successfully.

    modified:
      sql/protocol.cc
      sql/sql_cache.cc
      sql/sql_cursor.cc
      sql/sql_prepare.cc
=== modified file 'sql/protocol.cc'
--- a/sql/protocol.cc	2010-03-23 15:00:50 +0000
+++ b/sql/protocol.cc	2010-07-05 10:16:42 +0000
@@ -534,7 +534,10 @@ void Protocol::end_partial_result_set(TH
 bool Protocol::flush()
 {
 #ifndef EMBEDDED_LIBRARY
-  return net_flush(&thd->net);
+  thd->main_da.can_overwrite_status= TRUE;
+  bool error= net_flush(&thd->net);
+  thd->main_da.can_overwrite_status= FALSE;
+  return error;
 #else
   return 0;
 #endif
@@ -574,7 +577,8 @@ bool Protocol::send_fields(List<Item> *l
   if (flags & SEND_NUM_ROWS)
   {				// Packet with number of elements
     uchar *pos= net_store_length(buff, list->elements);
-    (void) my_net_write(&thd->net, buff, (size_t) (pos-buff));
+    if (my_net_write(&thd->net, buff, (size_t) (pos-buff)))
+      DBUG_RETURN(1);
   }
 
 #ifndef DBUG_OFF
@@ -698,7 +702,7 @@ bool Protocol::send_fields(List<Item> *l
     if (flags & SEND_DEFAULTS)
       item->send(&prot, &tmp);			// Send default value
     if (prot.write())
-      break;					/* purecov: inspected */
+      DBUG_RETURN(1);                           /* purecov: inspected */
 #ifndef DBUG_OFF
     field_types[count++]= field.type;
 #endif
@@ -711,7 +715,9 @@ bool Protocol::send_fields(List<Item> *l
       to show that there is no cursor.
       Send no warning information, as it will be sent at statement end.
     */
-    write_eof_packet(thd, &thd->net, thd->server_status, thd->total_warn_count);
+    if (write_eof_packet(thd, &thd->net, thd->server_status,
+                         thd->total_warn_count))
+      DBUG_RETURN(1);
   }
   DBUG_RETURN(prepare_for_send(list));
 

=== modified file 'sql/sql_cache.cc'
--- a/sql/sql_cache.cc	2009-11-20 12:49:06 +0000
+++ b/sql/sql_cache.cc	2010-07-05 10:16:42 +0000
@@ -1627,6 +1627,7 @@ def_week_frmt: %lu, in_trans: %d, autoco
   */
 #ifndef EMBEDDED_LIBRARY
   thd_proc_info(thd, "sending cached result to client");
+  thd->main_da.can_overwrite_status= TRUE;
   do
   {
     DBUG_PRINT("qcache", ("Results  (len: %lu  used: %lu  headers: %lu)",
@@ -1643,6 +1644,7 @@ def_week_frmt: %lu, in_trans: %d, autoco
     result_block = result_block->next;
     thd->net.pkt_nr= query->last_pkt_nr; // Keep packet number updated
   } while (result_block != first_result_block);
+  thd->main_da.can_overwrite_status= FALSE;
 #else
   {
     Querycache_stream qs(result_block, result_block->headers_len() +

=== modified file 'sql/sql_cursor.cc'
--- a/sql/sql_cursor.cc	2008-12-10 14:16:21 +0000
+++ b/sql/sql_cursor.cc	2010-07-05 10:16:42 +0000
@@ -658,7 +658,8 @@ void Materialized_cursor::fetch(ulong nu
     if ((res= table->file->rnd_next(table->record[0])))
       break;
     /* Send data only if the read was successful. */
-    result->send_data(item_list);
+    if (result->send_data(item_list))
+      return;
   }
 
   switch (res) {

=== modified file 'sql/sql_prepare.cc'
--- a/sql/sql_prepare.cc	2010-06-28 20:29:19 +0000
+++ b/sql/sql_prepare.cc	2010-07-05 10:16:42 +0000
@@ -263,8 +263,11 @@ static bool send_prep_stmt(Prepared_stat
                                           &stmt->lex->param_list,
                                           Protocol::SEND_EOF);
   }
-  /* Flag that a response has already been sent */
-  thd->main_da.disable_status();
+
+  if ( !error )
+    /* Flag that a response has already been sent */
+    thd->main_da.disable_status();
+
   DBUG_RETURN(error);
 }
 #else


Attachment: [text/bzr-bundle] bzr/dmitry.shulga@sun.com-20100705101642-1uwn0dn82coot9zf.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (Dmitry.Shulga:3454) Bug#42496Dmitry Shulga5 Jul
  • Re: bzr commit into mysql-5.1-bugteam branch (Dmitry.Shulga:3454)Bug#42496Konstantin Osipov8 Jul
  • Re: bzr commit into mysql-5.1-bugteam branch (Dmitry.Shulga:3454)Bug#42496Davi Arnaut13 Jul