wrap indirect calls to WHC in inline functions
Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
parent
3e343d032a
commit
f2f436bde3
9 changed files with 151 additions and 82 deletions
|
@ -96,7 +96,7 @@ struct whc_impl {
|
|||
};
|
||||
|
||||
struct whc_sample_iter_impl {
|
||||
struct whc_impl *whc;
|
||||
struct whc_sample_iter_base c;
|
||||
bool first;
|
||||
};
|
||||
|
||||
|
@ -135,39 +135,39 @@ static struct whc_node *whc_findseq (const struct whc_impl *whc, seqno_t seq);
|
|||
static void insert_whcn_in_hash (struct whc_impl *whc, struct whc_node *whcn);
|
||||
static void whc_delete_one (struct whc_impl *whc, struct whc_node *whcn);
|
||||
static int compare_seq (const void *va, const void *vb);
|
||||
static unsigned whc_remove_acked_messages_full (struct whc_impl *whc, seqno_t max_drop_seq, struct whc_node **deferred_free_list);
|
||||
static void free_deferred_free_list (struct whc_impl *whc, struct whc_node *deferred_free_list);
|
||||
static void get_state_locked(const struct whc_impl *whc, struct whc_state *st);
|
||||
|
||||
static unsigned whc_remove_acked_messages (struct whc *whc, seqno_t max_drop_seq, struct whc_state *whcst, struct whc_node **deferred_free_list);
|
||||
static void whc_free_deferred_free_list (struct whc *whc, struct whc_node *deferred_free_list);
|
||||
static void whc_get_state(const struct whc *whc, struct whc_state *st);
|
||||
static int whc_insert (struct whc *whc, seqno_t max_drop_seq, seqno_t seq, struct nn_plist *plist, struct ddsi_serdata *serdata, struct tkmap_instance *tk);
|
||||
static seqno_t whc_next_seq (const struct whc *whc, seqno_t seq);
|
||||
static bool whc_borrow_sample (const struct whc *whc, seqno_t seq, struct whc_borrowed_sample *sample);
|
||||
static bool whc_borrow_sample_key (const struct whc *whc, const struct ddsi_serdata *serdata_key, struct whc_borrowed_sample *sample);
|
||||
static void whc_return_sample (struct whc *whc, struct whc_borrowed_sample *sample, bool update_retransmit_info);
|
||||
static unsigned whc_downgrade_to_volatile (struct whc *whc, struct whc_state *st);
|
||||
static void whc_sample_iter_init (const struct whc *whc, struct whc_sample_iter *opaque_it);
|
||||
static bool whc_sample_iter_borrow_next (struct whc_sample_iter *opaque_it, struct whc_borrowed_sample *sample);
|
||||
static void whc_free (struct whc *whc);
|
||||
static unsigned whc_default_remove_acked_messages_full (struct whc_impl *whc, seqno_t max_drop_seq, struct whc_node **deferred_free_list);
|
||||
static unsigned whc_default_remove_acked_messages (struct whc *whc, seqno_t max_drop_seq, struct whc_state *whcst, struct whc_node **deferred_free_list);
|
||||
static void whc_default_free_deferred_free_list (struct whc *whc, struct whc_node *deferred_free_list);
|
||||
static void whc_default_get_state(const struct whc *whc, struct whc_state *st);
|
||||
static int whc_default_insert (struct whc *whc, seqno_t max_drop_seq, seqno_t seq, struct nn_plist *plist, struct ddsi_serdata *serdata, struct tkmap_instance *tk);
|
||||
static seqno_t whc_default_next_seq (const struct whc *whc, seqno_t seq);
|
||||
static bool whc_default_borrow_sample (const struct whc *whc, seqno_t seq, struct whc_borrowed_sample *sample);
|
||||
static bool whc_default_borrow_sample_key (const struct whc *whc, const struct ddsi_serdata *serdata_key, struct whc_borrowed_sample *sample);
|
||||
static void whc_default_return_sample (struct whc *whc, struct whc_borrowed_sample *sample, bool update_retransmit_info);
|
||||
static unsigned whc_default_downgrade_to_volatile (struct whc *whc, struct whc_state *st);
|
||||
static void whc_default_sample_iter_init (const struct whc *whc, struct whc_sample_iter *opaque_it);
|
||||
static bool whc_default_sample_iter_borrow_next (struct whc_sample_iter *opaque_it, struct whc_borrowed_sample *sample);
|
||||
static void whc_default_free (struct whc *whc);
|
||||
|
||||
static const ut_avlTreedef_t whc_seq_treedef =
|
||||
UT_AVL_TREEDEF_INITIALIZER (offsetof (struct whc_intvnode, avlnode), offsetof (struct whc_intvnode, min), compare_seq, 0);
|
||||
|
||||
static const struct whc_ops whc_ops = {
|
||||
.insert = whc_insert,
|
||||
.remove_acked_messages = whc_remove_acked_messages,
|
||||
.free_deferred_free_list = whc_free_deferred_free_list,
|
||||
.get_state = whc_get_state,
|
||||
.next_seq = whc_next_seq,
|
||||
.borrow_sample = whc_borrow_sample,
|
||||
.borrow_sample_key = whc_borrow_sample_key,
|
||||
.return_sample = whc_return_sample,
|
||||
.sample_iter_init = whc_sample_iter_init,
|
||||
.sample_iter_borrow_next = whc_sample_iter_borrow_next,
|
||||
.downgrade_to_volatile = whc_downgrade_to_volatile,
|
||||
.free = whc_free
|
||||
.insert = whc_default_insert,
|
||||
.remove_acked_messages = whc_default_remove_acked_messages,
|
||||
.free_deferred_free_list = whc_default_free_deferred_free_list,
|
||||
.get_state = whc_default_get_state,
|
||||
.next_seq = whc_default_next_seq,
|
||||
.borrow_sample = whc_default_borrow_sample,
|
||||
.borrow_sample_key = whc_default_borrow_sample_key,
|
||||
.return_sample = whc_default_return_sample,
|
||||
.sample_iter_init = whc_default_sample_iter_init,
|
||||
.sample_iter_borrow_next = whc_default_sample_iter_borrow_next,
|
||||
.downgrade_to_volatile = whc_default_downgrade_to_volatile,
|
||||
.free = whc_default_free
|
||||
};
|
||||
|
||||
#if USE_EHH
|
||||
|
@ -405,7 +405,7 @@ static void free_whc_node_contents (struct whc_node *whcn)
|
|||
}
|
||||
}
|
||||
|
||||
void whc_free (struct whc *whc_generic)
|
||||
void whc_default_free (struct whc *whc_generic)
|
||||
{
|
||||
/* Freeing stuff without regards for maintaining data structures */
|
||||
struct whc_impl * const whc = (struct whc_impl *)whc_generic;
|
||||
|
@ -467,7 +467,7 @@ static void get_state_locked(const struct whc_impl *whc, struct whc_state *st)
|
|||
}
|
||||
}
|
||||
|
||||
static void whc_get_state(const struct whc *whc_generic, struct whc_state *st)
|
||||
static void whc_default_get_state(const struct whc *whc_generic, struct whc_state *st)
|
||||
{
|
||||
const struct whc_impl * const whc = (const struct whc_impl *)whc_generic;
|
||||
os_mutexLock ((struct os_mutex *)&whc->lock);
|
||||
|
@ -518,7 +518,7 @@ static struct whc_node *find_nextseq_intv (struct whc_intvnode **p_intv, const s
|
|||
}
|
||||
}
|
||||
|
||||
static seqno_t whc_next_seq (const struct whc *whc_generic, seqno_t seq)
|
||||
static seqno_t whc_default_next_seq (const struct whc *whc_generic, seqno_t seq)
|
||||
{
|
||||
const struct whc_impl * const whc = (const struct whc_impl *)whc_generic;
|
||||
struct whc_node *n;
|
||||
|
@ -596,7 +596,7 @@ static int whcn_in_tlidx (const struct whc_impl *whc, const struct whc_idxnode *
|
|||
}
|
||||
}
|
||||
|
||||
static unsigned whc_downgrade_to_volatile (struct whc *whc_generic, struct whc_state *st)
|
||||
static unsigned whc_default_downgrade_to_volatile (struct whc *whc_generic, struct whc_state *st)
|
||||
{
|
||||
struct whc_impl * const whc = (struct whc_impl *)whc_generic;
|
||||
seqno_t old_max_drop_seq;
|
||||
|
@ -638,8 +638,8 @@ static unsigned whc_downgrade_to_volatile (struct whc *whc_generic, struct whc_s
|
|||
them all. */
|
||||
old_max_drop_seq = whc->max_drop_seq;
|
||||
whc->max_drop_seq = 0;
|
||||
cnt = whc_remove_acked_messages_full (whc, old_max_drop_seq, &deferred_free_list);
|
||||
whc_free_deferred_free_list (whc_generic, deferred_free_list);
|
||||
cnt = whc_default_remove_acked_messages_full (whc, old_max_drop_seq, &deferred_free_list);
|
||||
whc_default_free_deferred_free_list (whc_generic, deferred_free_list);
|
||||
assert (whc->max_drop_seq == old_max_drop_seq);
|
||||
get_state_locked(whc, st);
|
||||
os_mutexUnlock (&whc->lock);
|
||||
|
@ -789,13 +789,13 @@ static void free_deferred_free_list (struct whc_impl *whc, struct whc_node *defe
|
|||
}
|
||||
}
|
||||
|
||||
static void whc_free_deferred_free_list (struct whc *whc_generic, struct whc_node *deferred_free_list)
|
||||
static void whc_default_free_deferred_free_list (struct whc *whc_generic, struct whc_node *deferred_free_list)
|
||||
{
|
||||
struct whc_impl * const whc = (struct whc_impl *)whc_generic;
|
||||
free_deferred_free_list(whc, deferred_free_list);
|
||||
}
|
||||
|
||||
static unsigned whc_remove_acked_messages_noidx (struct whc_impl *whc, seqno_t max_drop_seq, struct whc_node **deferred_free_list)
|
||||
static unsigned whc_default_remove_acked_messages_noidx (struct whc_impl *whc, seqno_t max_drop_seq, struct whc_node **deferred_free_list)
|
||||
{
|
||||
struct whc_intvnode *intv;
|
||||
struct whc_node *whcn;
|
||||
|
@ -871,7 +871,7 @@ static unsigned whc_remove_acked_messages_noidx (struct whc_impl *whc, seqno_t m
|
|||
return ndropped;
|
||||
}
|
||||
|
||||
static unsigned whc_remove_acked_messages_full (struct whc_impl *whc, seqno_t max_drop_seq, struct whc_node **deferred_free_list)
|
||||
static unsigned whc_default_remove_acked_messages_full (struct whc_impl *whc, seqno_t max_drop_seq, struct whc_node **deferred_free_list)
|
||||
{
|
||||
struct whc_intvnode *intv;
|
||||
struct whc_node *whcn;
|
||||
|
@ -1005,7 +1005,7 @@ static unsigned whc_remove_acked_messages_full (struct whc_impl *whc, seqno_t ma
|
|||
return ndropped;
|
||||
}
|
||||
|
||||
static unsigned whc_remove_acked_messages (struct whc *whc_generic, seqno_t max_drop_seq, struct whc_state *whcst, struct whc_node **deferred_free_list)
|
||||
static unsigned whc_default_remove_acked_messages (struct whc *whc_generic, seqno_t max_drop_seq, struct whc_state *whcst, struct whc_node **deferred_free_list)
|
||||
{
|
||||
struct whc_impl * const whc = (struct whc_impl *)whc_generic;
|
||||
unsigned cnt;
|
||||
|
@ -1018,7 +1018,7 @@ static unsigned whc_remove_acked_messages (struct whc *whc_generic, seqno_t max_
|
|||
{
|
||||
struct whc_state tmp;
|
||||
get_state_locked(whc, &tmp);
|
||||
TRACE_WHC(("whc_remove_acked_messages(%p max_drop_seq %"PRId64")\n", (void *)whc, max_drop_seq));
|
||||
TRACE_WHC(("whc_default_remove_acked_messages(%p max_drop_seq %"PRId64")\n", (void *)whc, max_drop_seq));
|
||||
TRACE_WHC((" whc: [%"PRId64",%"PRId64"] max_drop_seq %"PRId64" h %u tl %u\n",
|
||||
tmp.min_seq, tmp.max_seq, whc->max_drop_seq, whc->hdepth, whc->tldepth));
|
||||
}
|
||||
|
@ -1026,15 +1026,15 @@ static unsigned whc_remove_acked_messages (struct whc *whc_generic, seqno_t max_
|
|||
check_whc (whc);
|
||||
|
||||
if (whc->idxdepth == 0)
|
||||
cnt = whc_remove_acked_messages_noidx (whc, max_drop_seq, deferred_free_list);
|
||||
cnt = whc_default_remove_acked_messages_noidx (whc, max_drop_seq, deferred_free_list);
|
||||
else
|
||||
cnt = whc_remove_acked_messages_full (whc, max_drop_seq, deferred_free_list);
|
||||
cnt = whc_default_remove_acked_messages_full (whc, max_drop_seq, deferred_free_list);
|
||||
get_state_locked(whc, whcst);
|
||||
os_mutexUnlock (&whc->lock);
|
||||
return cnt;
|
||||
}
|
||||
|
||||
static struct whc_node *whc_insert_seq (struct whc_impl *whc, seqno_t max_drop_seq, seqno_t seq, struct nn_plist *plist, struct ddsi_serdata *serdata)
|
||||
static struct whc_node *whc_default_insert_seq (struct whc_impl *whc, seqno_t max_drop_seq, seqno_t seq, struct nn_plist *plist, struct ddsi_serdata *serdata)
|
||||
{
|
||||
struct whc_node *newn = NULL;
|
||||
|
||||
|
@ -1095,7 +1095,7 @@ static struct whc_node *whc_insert_seq (struct whc_impl *whc, seqno_t max_drop_s
|
|||
return newn;
|
||||
}
|
||||
|
||||
static int whc_insert (struct whc *whc_generic, seqno_t max_drop_seq, seqno_t seq, struct nn_plist *plist, struct ddsi_serdata *serdata, struct tkmap_instance *tk)
|
||||
static int whc_default_insert (struct whc *whc_generic, seqno_t max_drop_seq, seqno_t seq, struct nn_plist *plist, struct ddsi_serdata *serdata, struct tkmap_instance *tk)
|
||||
{
|
||||
struct whc_impl * const whc = (struct whc_impl *)whc_generic;
|
||||
struct whc_node *newn = NULL;
|
||||
|
@ -1112,7 +1112,7 @@ static int whc_insert (struct whc *whc_generic, seqno_t max_drop_seq, seqno_t se
|
|||
{
|
||||
struct whc_state whcst;
|
||||
get_state_locked(whc, &whcst);
|
||||
TRACE_WHC(("whc_insert(%p max_drop_seq %"PRId64" seq %"PRId64" plist %p serdata %p:%"PRIx32")\n", (void *)whc, max_drop_seq, seq, (void*)plist, (void*)serdata, serdata->hash));
|
||||
TRACE_WHC(("whc_default_insert(%p max_drop_seq %"PRId64" seq %"PRId64" plist %p serdata %p:%"PRIx32")\n", (void *)whc, max_drop_seq, seq, (void*)plist, (void*)serdata, serdata->hash));
|
||||
TRACE_WHC((" whc: [%"PRId64",%"PRId64"] max_drop_seq %"PRId64" h %u tl %u\n",
|
||||
whcst.min_seq, whcst.max_seq, whc->max_drop_seq, whc->hdepth, whc->tldepth));
|
||||
}
|
||||
|
@ -1126,7 +1126,7 @@ static int whc_insert (struct whc *whc_generic, seqno_t max_drop_seq, seqno_t se
|
|||
assert (whc->seq_size == 0 || seq > whc->maxseq_node->seq);
|
||||
|
||||
/* Always insert in seq admin */
|
||||
newn = whc_insert_seq (whc, max_drop_seq, seq, plist, serdata);
|
||||
newn = whc_default_insert_seq (whc, max_drop_seq, seq, plist, serdata);
|
||||
|
||||
TRACE_WHC((" whcn %p:", (void*)newn));
|
||||
|
||||
|
@ -1179,7 +1179,7 @@ static int whc_insert (struct whc *whc_generic, seqno_t max_drop_seq, seqno_t se
|
|||
/* Special case for dropping everything beyond T-L history when the new sample is being
|
||||
auto-acknowledged (for lack of reliable readers), and the keep-last T-L history is
|
||||
shallower than the keep-last regular history (normal path handles this via pruning in
|
||||
whc_remove_acked_messages, but that never happens when there are no readers). */
|
||||
whc_default_remove_acked_messages, but that never happens when there are no readers). */
|
||||
if (seq <= max_drop_seq && whc->tldepth > 0 && whc->idxdepth > whc->tldepth)
|
||||
{
|
||||
unsigned pos = idxn->headidx + whc->idxdepth - whc->tldepth;
|
||||
|
@ -1246,7 +1246,7 @@ static void make_borrowed_sample(struct whc_borrowed_sample *sample, struct whc_
|
|||
sample->last_rexmit_ts = whcn->last_rexmit_ts;
|
||||
}
|
||||
|
||||
static bool whc_borrow_sample (const struct whc *whc_generic, seqno_t seq, struct whc_borrowed_sample *sample)
|
||||
static bool whc_default_borrow_sample (const struct whc *whc_generic, seqno_t seq, struct whc_borrowed_sample *sample)
|
||||
{
|
||||
const struct whc_impl * const whc = (const struct whc_impl *)whc_generic;
|
||||
struct whc_node *whcn;
|
||||
|
@ -1263,7 +1263,7 @@ static bool whc_borrow_sample (const struct whc *whc_generic, seqno_t seq, struc
|
|||
return found;
|
||||
}
|
||||
|
||||
static bool whc_borrow_sample_key (const struct whc *whc_generic, const struct ddsi_serdata *serdata_key, struct whc_borrowed_sample *sample)
|
||||
static bool whc_default_borrow_sample_key (const struct whc *whc_generic, const struct ddsi_serdata *serdata_key, struct whc_borrowed_sample *sample)
|
||||
{
|
||||
const struct whc_impl * const whc = (const struct whc_impl *)whc_generic;
|
||||
struct whc_node *whcn;
|
||||
|
@ -1304,7 +1304,7 @@ static void return_sample_locked (struct whc_impl *whc, struct whc_borrowed_samp
|
|||
}
|
||||
}
|
||||
|
||||
static void whc_return_sample (struct whc *whc_generic, struct whc_borrowed_sample *sample, bool update_retransmit_info)
|
||||
static void whc_default_return_sample (struct whc *whc_generic, struct whc_borrowed_sample *sample, bool update_retransmit_info)
|
||||
{
|
||||
struct whc_impl * const whc = (struct whc_impl *)whc_generic;
|
||||
os_mutexLock (&whc->lock);
|
||||
|
@ -1312,18 +1312,17 @@ static void whc_return_sample (struct whc *whc_generic, struct whc_borrowed_samp
|
|||
os_mutexUnlock (&whc->lock);
|
||||
}
|
||||
|
||||
static void whc_sample_iter_init (const struct whc *whc_generic, struct whc_sample_iter *opaque_it)
|
||||
static void whc_default_sample_iter_init (const struct whc *whc_generic, struct whc_sample_iter *opaque_it)
|
||||
{
|
||||
const struct whc_impl * const whc = (const struct whc_impl *)whc_generic;
|
||||
struct whc_sample_iter_impl *it = (struct whc_sample_iter_impl *)opaque_it->opaque.opaque;
|
||||
it->whc = (struct whc_impl *)whc;
|
||||
struct whc_sample_iter_impl *it = (struct whc_sample_iter_impl *)opaque_it;
|
||||
it->c.whc = (struct whc *)whc_generic;
|
||||
it->first = true;
|
||||
}
|
||||
|
||||
static bool whc_sample_iter_borrow_next (struct whc_sample_iter *opaque_it, struct whc_borrowed_sample *sample)
|
||||
static bool whc_default_sample_iter_borrow_next (struct whc_sample_iter *opaque_it, struct whc_borrowed_sample *sample)
|
||||
{
|
||||
struct whc_sample_iter_impl * const it = (struct whc_sample_iter_impl *)opaque_it->opaque.opaque;
|
||||
struct whc_impl * const whc = it->whc;
|
||||
struct whc_sample_iter_impl * const it = (struct whc_sample_iter_impl *)opaque_it;
|
||||
struct whc_impl * const whc = (struct whc_impl *)it->c.whc;
|
||||
struct whc_node *whcn;
|
||||
struct whc_intvnode *intv;
|
||||
seqno_t seq;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue