Skip to content

Commit

Permalink
tevent: add trace points BEFORE_LOOP_ONCE and AFTER_LOOP_ONCE
Browse files Browse the repository at this point in the history
The define TEVENT_HAS_LOOP_ONCE_TRACE_POINTS can be used to
detect the new feature, without writing configure tests.

Pair-Programmed-With: Stefan Metzmacher <[email protected]>

Signed-off-by: Michael Adam <[email protected]>
Signed-off-by: Stefan Metzmacher <[email protected]>
  • Loading branch information
obnoxxx authored and jrasamba committed Mar 1, 2013
1 parent 5f284be commit 883d20a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/tevent/testsuite.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ static void test_event_threaded_trace(enum tevent_trace_point point,
case TEVENT_TRACE_AFTER_WAIT:
test_event_threaded_lock();
break;
case TEVENT_TRACE_BEFORE_LOOP_ONCE:
case TEVENT_TRACE_AFTER_LOOP_ONCE:
break;
}
}

Expand Down
4 changes: 4 additions & 0 deletions lib/tevent/tevent.c
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,9 @@ int _tevent_loop_once(struct tevent_context *ev, const char *location)
}
}

tevent_trace_point_callback(ev, TEVENT_TRACE_BEFORE_LOOP_ONCE);
ret = ev->ops->loop_once(ev, location);
tevent_trace_point_callback(ev, TEVENT_TRACE_AFTER_LOOP_ONCE);

if (ev->nesting.level > 0) {
if (ev->nesting.hook_fn) {
Expand Down Expand Up @@ -585,7 +587,9 @@ int _tevent_loop_until(struct tevent_context *ev,
}

while (!finished(private_data)) {
tevent_trace_point_callback(ev, TEVENT_TRACE_BEFORE_LOOP_ONCE);
ret = ev->ops->loop_once(ev, location);
tevent_trace_point_callback(ev, TEVENT_TRACE_AFTER_LOOP_ONCE);
if (ret != 0) {
break;
}
Expand Down
11 changes: 11 additions & 0 deletions lib/tevent/tevent.h
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,17 @@ enum tevent_trace_point {
* Corresponds to a trace point just after waiting
*/
TEVENT_TRACE_AFTER_WAIT,
#define TEVENT_HAS_LOOP_ONCE_TRACE_POINTS 1
/**
* Corresponds to a trace point just before calling
* the loop_once() backend function.
*/
TEVENT_TRACE_BEFORE_LOOP_ONCE,
/**
* Corresponds to a trace point right after the
* loop_once() backend function has returned.
*/
TEVENT_TRACE_AFTER_LOOP_ONCE,
};

typedef void (*tevent_trace_callback_t)(enum tevent_trace_point,
Expand Down

0 comments on commit 883d20a

Please sign in to comment.