TT#14008 add log_info_pop_until()

To safeguard against non-refcounted objects being left over in a log
info piece (e.g. a string on the stack), add this new function to pop
pieces from the stack until the desired one is removed. This is needed
in case of a unpaired log_info_* without a matching log_info_pop.

closes #1511

Change-Id: I689de14d034df779521dfdf59f923fdbf7fabc9b
(cherry picked from commit 59a16e747b)
mr10.5.2
Richard Fuchs 3 years ago
parent 31199a6ddf
commit eda18f1e2a

@ -399,7 +399,7 @@ send_only:
out:
ng_buffer_release(ngbuf);
release_closed_sockets();
log_info_pop();
log_info_pop_until(&callid);
return funcret;
}

@ -47,6 +47,16 @@ INLINE void log_info_pop(void) {
g_slice_free1(sizeof(*next), next);
log_info_stack = g_slist_delete_link(log_info_stack, log_info_stack);
}
// should be used with non-refcounted log info pieces
INLINE void log_info_pop_until(void *p) {
assert(p != NULL);
while (log_info.u.ptr) {
void *prev = log_info.u.ptr;
log_info_pop();
if (prev == p)
break;
}
}
// clears current log context and entire stack
INLINE void log_info_reset(void) {
__log_info_release(&log_info);

@ -12,6 +12,8 @@ INLINE void log_info_reset(void) {
}
INLINE void log_info_pop(void) {
}
INLINE void log_info_pop_until(void *p) {
}
INLINE void log_info_call(struct call *c) {
}
INLINE void log_info_stream_fd(struct stream_fd *sfd) {

Loading…
Cancel
Save