Commit 4b75440b authored by unknown's avatar unknown

Post-review fixes + some locking cleanup.


storage/maria/ma_loghandler.c:
  translog_lock() made safe (non-mutex-protected operation is atomic now).
  Fixed translog_destroy() because it will not work to be
    called several times.
parent a2d1a8c0
...@@ -2362,7 +2362,7 @@ static my_bool translog_page_validator(uchar *page_addr, uchar* data_ptr) ...@@ -2362,7 +2362,7 @@ static my_bool translog_page_validator(uchar *page_addr, uchar* data_ptr)
my_bool translog_lock() my_bool translog_lock()
{ {
struct st_translog_buffer *current_buffer; uint8 current_buffer;
DBUG_ENTER("translog_lock"); DBUG_ENTER("translog_lock");
/* /*
...@@ -2371,12 +2371,16 @@ my_bool translog_lock() ...@@ -2371,12 +2371,16 @@ my_bool translog_lock()
*/ */
for (;;) for (;;)
{ {
current_buffer= log_descriptor.bc.buffer; /*
if (translog_buffer_lock(current_buffer)) log_descriptor.bc.buffer_no is only one byte so its reading is
an atomic operation
*/
current_buffer= log_descriptor.bc.buffer_no;
if (translog_buffer_lock(log_descriptor.buffers + current_buffer))
DBUG_RETURN(1); DBUG_RETURN(1);
if (log_descriptor.bc.buffer == current_buffer) if (log_descriptor.bc.buffer_no == current_buffer)
break; break;
translog_buffer_unlock(current_buffer); translog_buffer_unlock(log_descriptor.buffers + current_buffer);
} }
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -3348,10 +3352,12 @@ void translog_destroy() ...@@ -3348,10 +3352,12 @@ void translog_destroy()
uint i; uint i;
DBUG_ENTER("translog_destroy"); DBUG_ENTER("translog_destroy");
if (translog_inited) DBUG_ASSERT(translog_inited);
{ translog_lock();
translog_inited= 0;
if (log_descriptor.bc.buffer->file != -1) if (log_descriptor.bc.buffer->file != -1)
translog_finish_page(&log_descriptor.horizon, &log_descriptor.bc); translog_finish_page(&log_descriptor.horizon, &log_descriptor.bc);
translog_unlock();
for (i= 0; i < TRANSLOG_BUFFERS_NO; i++) for (i= 0; i < TRANSLOG_BUFFERS_NO; i++)
{ {
...@@ -3375,8 +3381,6 @@ void translog_destroy() ...@@ -3375,8 +3381,6 @@ void translog_destroy()
my_close(log_descriptor.directory_fd, MYF(MY_WME)); my_close(log_descriptor.directory_fd, MYF(MY_WME));
my_atomic_rwlock_destroy(&LOCK_id_to_share); my_atomic_rwlock_destroy(&LOCK_id_to_share);
my_free((uchar*)(id_to_share + 1), MYF(MY_ALLOW_ZERO_PTR)); my_free((uchar*)(id_to_share + 1), MYF(MY_ALLOW_ZERO_PTR));
translog_inited= 0;
}
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
...@@ -3803,6 +3807,7 @@ static my_bool translog_advance_pointer(uint pages, uint16 last_page_data) ...@@ -3803,6 +3807,7 @@ static my_bool translog_advance_pointer(uint pages, uint16 last_page_data)
log_descriptor.bc.current_page_fill), log_descriptor.bc.current_page_fill),
pages, (uint) log_descriptor.page_overhead, pages, (uint) log_descriptor.page_overhead,
(uint) last_page_data)); (uint) last_page_data));
translog_lock_assert_owner();
for (;;) for (;;)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment