From 6f118237d44350dd553dc4e82081dc40868eaa66 Mon Sep 17 00:00:00 2001 From: Rahim Kanji Date: Sun, 27 Oct 2024 18:27:17 +0500 Subject: [PATCH] Implemented overflow-safe multiplication for mysql_thread___threshold_resultset_size --- lib/MySQL_Thread.cpp | 2 +- lib/mysql_connection.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/MySQL_Thread.cpp b/lib/MySQL_Thread.cpp index eaf60184b..e90361213 100644 --- a/lib/MySQL_Thread.cpp +++ b/lib/MySQL_Thread.cpp @@ -5995,7 +5995,7 @@ bool MySQL_Thread::set_backend_to_be_skipped_if_frontend_is_slow(MySQL_Data_Stre // we pause receiving from backend at mysql_thread___threshold_resultset_size * 8 // but assuming that client isn't completely blocked, we will stop checking for data // only at mysql_thread___threshold_resultset_size * 4 - if (buffered_data > (unsigned int)mysql_thread___threshold_resultset_size*4) { + if (buffered_data > overflow_safe_multiply<4,unsigned int>(mysql_thread___threshold_resultset_size)) { mypolls.fds[n].events = 0; return true; } diff --git a/lib/mysql_connection.cpp b/lib/mysql_connection.cpp index 97936f4ec..d795f1aac 100644 --- a/lib/mysql_connection.cpp +++ b/lib/mysql_connection.cpp @@ -1509,7 +1509,7 @@ handler_again: unsigned int buffered_data=0; buffered_data = myds->sess->client_myds->PSarrayOUT->len * RESULTSET_BUFLEN; buffered_data += myds->sess->client_myds->resultset->len * RESULTSET_BUFLEN; - if (buffered_data > (unsigned int)mysql_thread___threshold_resultset_size*8) { + if (buffered_data > overflow_safe_multiply<8,unsigned int>(mysql_thread___threshold_resultset_size)) { next_event(ASYNC_STMT_EXECUTE_STORE_RESULT_CONT); // we temporarily pause . See #1232 break; } @@ -1535,7 +1535,7 @@ handler_again: if (rows_read_inner > 1) { process_rows_in_ASYNC_STMT_EXECUTE_STORE_RESULT_CONT(processed_bytes); if ( - (processed_bytes > (unsigned int)mysql_thread___threshold_resultset_size*8) + (processed_bytes > overflow_safe_multiply<8,unsigned int>(mysql_thread___threshold_resultset_size)) || ( mysql_thread___throttle_ratio_server_to_client && mysql_thread___throttle_max_bytes_per_second_to_client && (processed_bytes > (unsigned long long)mysql_thread___throttle_max_bytes_per_second_to_client/10*(unsigned long long)mysql_thread___throttle_ratio_server_to_client) ) ) { @@ -1688,7 +1688,7 @@ handler_again: unsigned int buffered_data=0; buffered_data = myds->sess->client_myds->PSarrayOUT->len * RESULTSET_BUFLEN; buffered_data += myds->sess->client_myds->resultset->len * RESULTSET_BUFLEN; - if (buffered_data > (unsigned int)mysql_thread___threshold_resultset_size*8) { + if (buffered_data > overflow_safe_multiply<8,unsigned int>(mysql_thread___threshold_resultset_size)) { next_event(ASYNC_USE_RESULT_CONT); // we temporarily pause . See #1232 break; } @@ -1742,7 +1742,7 @@ handler_again: bytes_info.bytes_recv += br; processed_bytes+=br; // issue #527 : this variable will store the amount of bytes processed during this event if ( - (processed_bytes > (unsigned int)mysql_thread___threshold_resultset_size*8) + (processed_bytes > overflow_safe_multiply<8,unsigned int>(mysql_thread___threshold_resultset_size)) || ( mysql_thread___throttle_ratio_server_to_client && mysql_thread___throttle_max_bytes_per_second_to_client && (processed_bytes > (unsigned long long)mysql_thread___throttle_max_bytes_per_second_to_client/10*(unsigned long long)mysql_thread___throttle_ratio_server_to_client) ) ) {