Commit ab9c28d3 authored by Yossi Gottlieb's avatar Yossi Gottlieb
Browse files

Fix memory access issues in tests, update docs.

parent 84362fa7
......@@ -1130,14 +1130,20 @@ typedef struct {
/** Callback for removing the oldest entry from the log
* For safety reasons this callback MUST flush the change to disk.
* @note If memory was malloc'd in log_offer then this should be the right
* time to free the memory. */
* @note The callback does not need to call raft_entry_release() as
* no references are implicitly held. If access to the entry is
* desired after the callback returns, raft_entry_hold() should be
* used.
*/
func_logentry_event_f log_poll;
/** Callback for removing the youngest entry from the log
* For safety reasons this callback MUST flush the change to disk.
* @note If memory was malloc'd in log_offer then this should be the right
* time to free the memory. */
* @note The callback does not need to call raft_entry_release() as
* no references are implicitly held. If access to the entry is
* desired after the callback returns, raft_entry_hold() should be
* used.
*/
func_logentry_event_f log_pop;
/** Callback called for every existing log entry when clearing the log.
......
......@@ -17,6 +17,7 @@
static void __LOG_APPEND_ENTRY(void *l, int id, raft_term_t term, const char *data)
{
raft_entry_t *e = __MAKE_ENTRY(id, term, data);
raft_entry_hold(e); /* need an extra ref because tests assume it lives on */
log_append_entry(l, e);
}
......@@ -25,6 +26,7 @@ static void __LOG_APPEND_ENTRIES_SEQ_ID(void *l, int count, int id, raft_term_t
int i;
for (i = 0; i < count; i++) {
raft_entry_t *e = __MAKE_ENTRY(id++, term, data);
raft_entry_hold(e); /* need an extra ref because tests assume it lives on */
log_append_entry(l, e);
}
}
......
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