From: Jonas Oreland Date: January 25 2012 3:41pm Subject: bzr push into mysql-5.1-telco-7.0 branch (jonas.oreland:4823 to 4824) Bug#13618181 List-Archive: http://lists.mysql.com/commits/142546 X-Bug: 13618181 Message-Id: <20120125154111.1FFBB55C2B5@perch.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 4824 Jonas Oreland 2012-01-25 ndb - bug#13618181 - add packing on send-buffer pages in one place modified: storage/ndb/src/kernel/vm/mt.cpp 4823 Jonas Oreland 2012-01-25 ndb - fix regression introduced in fix for bug-13602508 modified: storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp === modified file 'storage/ndb/src/kernel/vm/mt.cpp' --- a/storage/ndb/src/kernel/vm/mt.cpp 2012-01-25 12:32:36 +0000 +++ b/storage/ndb/src/kernel/vm/mt.cpp 2012-01-25 15:40:19 +0000 @@ -2392,6 +2392,50 @@ release_list(thread_local_poolrelease_local(tail); } +/** + * pack thr_send_pages for a particular send-buffer db + * release pages (local) to pool + * + * can only be called with sb->m_lock held + */ +static +void +pack_sb_pages(thread_local_pool* pool, + thr_repository::send_buffer* sb) +{ + assert(sb->m_buffer.m_first_page != 0); + assert(sb->m_buffer.m_last_page != 0); + assert(sb->m_buffer.m_last_page->m_next == 0); + + thr_send_page* curr = sb->m_buffer.m_first_page; + Uint32 curr_free = curr->max_bytes() - (curr->m_bytes + curr->m_start); + while (curr->m_next != 0) + { + thr_send_page* next = curr->m_next; + assert(next->m_start == 0); // only first page should have half sent bytes + if (next->m_bytes <= curr_free) + { + thr_send_page * save = next; + memcpy(curr->m_data + (curr->m_bytes + curr->m_start), + next->m_data, + next->m_bytes); + + curr_free -= next->m_bytes; + + curr->m_bytes += next->m_bytes; + curr->m_next = next->m_next; + + pool->release_local(save); + } + else + { + curr = next; + curr_free = curr->max_bytes() - (curr->m_bytes + curr->m_start); + } + } + + sb->m_buffer.m_last_page = curr; +} static Uint32 @@ -2455,6 +2499,14 @@ bytes_sent(thread_local_poolm_buffer.m_first_page = curr; assert(sb->m_bytes > bytes); sb->m_bytes -= bytes; + + /** + * Since not all bytes were sent... + * spend the time to try to pack the pages + * possibly releasing send-buffer + */ + pack_sb_pages(pool, sb); + return sb->m_bytes; } No bundle (reason: useless for push emails).