Skip to content

Commit

Permalink
event: More dbugging
Browse files Browse the repository at this point in the history
  • Loading branch information
arr2036 committed May 1, 2020
1 parent 2a4217d commit f3ce2ce
Show file tree
Hide file tree
Showing 4 changed files with 247 additions and 114 deletions.
15 changes: 15 additions & 0 deletions src/include/build.h
Expand Up @@ -82,6 +82,21 @@ extern "C" {
# define HEXIFY(b1) XHEXIFY(b1)
#endif

/*
* Pass caller information to the function
*/
#ifndef NDEBUG
# define NDEBUG_LOCATION_ARGS char const *file, int line,
# define NDEBUG_LOCATION_VALS file, line,
# define NDEBUG_LOCATION_EXP __FILE__, __LINE__,
# define NDEBUG_LOCATION_NONNULL(_num) ((_num) + 2)
#else
# define NDEBUG_LOCATION_ARGS
# define NDEBUG_LOCATION_VALS
# define NDEBUG_LOCATION_EXP
# define NDEBUG_LOCATION_NONNULL(_num) (_num)
#endif

/*
* Mark variables as unused
*/
Expand Down
9 changes: 2 additions & 7 deletions src/lib/io/control.c
Expand Up @@ -83,10 +83,6 @@ struct fr_control_s {

int pipe[2]; //!< our pipes

#ifndef NDEBUG
uint32_t armour; //!< to protect ourself from deletion.
#endif

bool same_thread; //!< are the two ends in the same thread

fr_control_ctx_t type[FR_CONTROL_MAX_TYPES]; //!< callbacks
Expand Down Expand Up @@ -131,7 +127,7 @@ static int _control_free(fr_control_t *c)
(void) talloc_get_type_abort(c, fr_control_t);

#ifndef NDEBUG
(void) fr_event_fd_unarmour(c->el, c->pipe[0], FR_EVENT_FILTER_IO, c->armour);
(void) fr_event_fd_unarmour(c->el, c->pipe[0], FR_EVENT_FILTER_IO, (uintptr_t)c);
#endif
(void) fr_event_fd_delete(c->el, c->pipe[0], FR_EVENT_FILTER_IO);

Expand Down Expand Up @@ -182,8 +178,7 @@ fr_control_t *fr_control_create(TALLOC_CTX *ctx, fr_event_list_t *el, fr_atomic_
}

#ifndef NDEBUG
c->armour = fr_rand();
(void) fr_event_fd_armour(c->el, c->pipe[0], FR_EVENT_FILTER_IO, c->armour);
(void) fr_event_fd_armour(c->el, c->pipe[0], FR_EVENT_FILTER_IO, (uintptr_t)c);
#endif

return c;
Expand Down

0 comments on commit f3ce2ce

Please sign in to comment.