mirror of
https://github.com/MariaDB/server.git
synced 2026-05-02 21:25:36 +02:00
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: call to thd->main_da.disable_status() only if write to socket was successful. 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.
This commit is contained in:
parent
7ccbf9b817
commit
bd41af86eb
4 changed files with 24 additions and 8 deletions
|
|
@ -534,7 +534,11 @@ void Protocol::end_partial_result_set(THD *thd_arg)
|
|||
bool Protocol::flush()
|
||||
{
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
return net_flush(&thd->net);
|
||||
bool error;
|
||||
thd->main_da.can_overwrite_status= TRUE;
|
||||
error= net_flush(&thd->net);
|
||||
thd->main_da.can_overwrite_status= FALSE;
|
||||
return error;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
|
|
@ -574,7 +578,8 @@ bool Protocol::send_fields(List<Item> *list, uint flags)
|
|||
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 +703,7 @@ bool Protocol::send_fields(List<Item> *list, uint flags)
|
|||
if (flags & SEND_DEFAULTS)
|
||||
item->send(&prot, &tmp); // Send default value
|
||||
if (prot.write())
|
||||
break; /* purecov: inspected */
|
||||
DBUG_RETURN(1);
|
||||
#ifndef DBUG_OFF
|
||||
field_types[count++]= field.type;
|
||||
#endif
|
||||
|
|
@ -711,7 +716,9 @@ bool Protocol::send_fields(List<Item> *list, uint flags)
|
|||
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));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue