Skip to content

Commit

Permalink
[C]: for #424. Reflect Java changes for unblock.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmontgomery committed Oct 27, 2017
1 parent 1cf0538 commit dc44c82
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions aeron-driver/src/main/c/concurrent/aeron_logbuffer_unblocker.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,28 @@ bool aeron_logbuffer_unblocker_unblock(
AERON_GET_VOLATILE(active_term_count, log_meta_data->active_term_count);
const int32_t expected_term_count = (int32_t)(blocked_position >> position_bits_to_shift);

const size_t index = aeron_logbuffer_index_by_term_count(active_term_count);
const size_t index = aeron_logbuffer_index_by_term_count(expected_term_count);

int64_t raw_tail;

AERON_GET_VOLATILE(raw_tail, log_meta_data->term_tail_counters[index]);
const int32_t term_id = aeron_logbuffer_term_id(raw_tail);

if (active_term_count == (expected_term_count - 1) && 0 == (blocked_position & (term_length - 1)))
{
return aeron_logbuffer_rotate_log(log_meta_data, active_term_count, term_id);
}

const int32_t tail_offset = aeron_logbuffer_term_offset(raw_tail, (int32_t)term_length);
const int32_t blocked_offset =
aeron_logbuffer_compute_term_offset_from_position(blocked_position, position_bits_to_shift);

if (active_term_count == (expected_term_count - 1) && 0 == blocked_offset)
{
int64_t current_raw_tail;

AERON_GET_VOLATILE(
current_raw_tail,
log_meta_data->term_tail_counters[aeron_logbuffer_index_by_term_count(active_term_count)]);
const int32_t current_term_id = aeron_logbuffer_term_id(current_raw_tail);

return aeron_logbuffer_rotate_log(log_meta_data, active_term_count, current_term_id);
}

switch (aeron_term_unblocker_unblock(
log_meta_data, term_buffers[index].addr, term_length, blocked_offset, tail_offset, term_id))
{
Expand Down

0 comments on commit dc44c82

Please sign in to comment.