common: Resume the startup trace after exiting io_loop
This was a bit harder to identify: during an `io_loop` run we suspend the current span before handing over to `io_loop`, and later when a callback is called we resume the span again. Depending on how we return from the `io_loop` instance that is used to drive the startup, we either have resumed the last span, or we don't. Since we start a span before `io_loop` and want it to be emitted afterwards, we need to take care of the case where we returned from a callback that did not resume, and therefore the current context is empty. Making `trace_span_resume` idempotent means we can just resume it manually. Ideally we'd push the suspend / resume logic down into `io_loop` itself, and then we'd have just one place. Maybe suspend and resume callbacks that can be configured in `io_loop`?
This commit is contained in:
committed by
Rusty Russell
parent
1900dd53bf
commit
57b9648d30
@@ -1412,6 +1412,14 @@ int main(int argc, char *argv[])
|
||||
/*~ Now handle sigchld, so we can clean up appropriately. */
|
||||
sigchld_conn = notleak(io_new_conn(ld, sigchld_rfd, sigchld_rfd_in, ld));
|
||||
|
||||
/* This span was started before handing control to `io_loop`
|
||||
* which suspends active spans in-between processing
|
||||
* events. Depending on how the `io_loop` was interrupted, the
|
||||
* current context span may have been suspended. We need to
|
||||
* manually resume it for this case. Notice that resuming is
|
||||
* idempotent, and doing so repeatedly is safe.
|
||||
*/
|
||||
trace_span_resume(argv);
|
||||
trace_span_end(argv);
|
||||
|
||||
/*~ Mark ourselves live.
|
||||
|
||||
@@ -263,6 +263,9 @@ void towire_node_id(u8 **pptr UNNEEDED, const struct node_id *id UNNEEDED)
|
||||
/* Generated stub for trace_span_end */
|
||||
void trace_span_end(const void *key UNNEEDED)
|
||||
{ fprintf(stderr, "trace_span_end called!\n"); abort(); }
|
||||
/* Generated stub for trace_span_resume_ */
|
||||
void trace_span_resume_(const void *key UNNEEDED, const char *lbl UNNEEDED)
|
||||
{ fprintf(stderr, "trace_span_resume_ called!\n"); abort(); }
|
||||
/* Generated stub for trace_span_start */
|
||||
void trace_span_start(const char *name UNNEEDED, const void *key UNNEEDED)
|
||||
{ fprintf(stderr, "trace_span_start called!\n"); abort(); }
|
||||
|
||||
Reference in New Issue
Block a user