blob: efe8fe29f632438f1481219f7d70ceba3c4348fa [file] [log] [blame]
Miroslav Zagorac70230c62020-12-09 16:54:31 +01001/***
2 * Copyright 2020 HAProxy Technologies
3 *
4 * This file is part of the HAProxy OpenTracing filter.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 */
20#include "include.h"
21
22
Willy Tarreauff882702021-04-10 17:23:00 +020023static struct pool_head *pool_head_ot_scope_span __read_mostly = NULL;
24static struct pool_head *pool_head_ot_scope_context __read_mostly = NULL;
25static struct pool_head *pool_head_ot_runtime_context __read_mostly = NULL;
Miroslav Zagorac70230c62020-12-09 16:54:31 +010026
27#ifdef USE_POOL_OT_SCOPE_SPAN
28REGISTER_POOL(&pool_head_ot_scope_span, "ot_scope_span", sizeof(struct flt_ot_scope_span));
29#endif
30#ifdef USE_POOL_OT_SCOPE_CONTEXT
31REGISTER_POOL(&pool_head_ot_scope_context, "ot_scope_context", sizeof(struct flt_ot_scope_context));
32#endif
33#ifdef USE_POOL_OT_RUNTIME_CONTEXT
34REGISTER_POOL(&pool_head_ot_runtime_context, "ot_runtime_context", sizeof(struct flt_ot_runtime_context));
35#endif
36
37
38#ifdef DEBUG_OT
39
40/***
41 * NAME
42 * flt_ot_pools_info -
43 *
44 * ARGUMENTS
45 * This function takes no arguments.
46 *
47 * DESCRIPTION
48 * -
49 *
50 * RETURN VALUE
51 * This function does not return a value.
52 */
53void flt_ot_pools_info(void)
54{
55 /*
56 * In case we have some error in the configuration file,
57 * it is possible that this pool was not initialized.
58 */
59#ifdef USE_POOL_BUFFER
60 FLT_OT_DBG(2, "sizeof_pool(buffer) = %u", FLT_OT_DEREF(pool_head_buffer, size, 0));
61#endif
62#ifdef USE_TRASH_CHUNK
63 FLT_OT_DBG(2, "sizeof_pool(trash) = %u", FLT_OT_DEREF(pool_head_trash, size, 0));
64#endif
65
66#ifdef USE_POOL_OT_SCOPE_SPAN
67 FLT_OT_DBG(2, "sizeof_pool(ot_scope_span) = %u", pool_head_ot_scope_span->size);
68#endif
69#ifdef USE_POOL_OT_SCOPE_CONTEXT
70 FLT_OT_DBG(2, "sizeof_pool(ot_scope_context) = %u", pool_head_ot_scope_context->size);
71#endif
72#ifdef USE_POOL_OT_RUNTIME_CONTEXT
73 FLT_OT_DBG(2, "sizeof_pool(ot_runtime_context) = %u", pool_head_ot_runtime_context->size);
74#endif
75}
76
77#endif /* DEBUG_OT */
78
79
80/***
81 * NAME
82 * flt_ot_runtime_context_init -
83 *
84 * ARGUMENTS
85 * s -
86 * f -
87 * err -
88 *
89 * DESCRIPTION
90 * -
91 *
92 * RETURN VALUE
93 * -
94 */
95struct flt_ot_runtime_context *flt_ot_runtime_context_init(struct stream *s, struct filter *f, char **err)
96{
97 const struct flt_ot_conf *conf = FLT_OT_CONF(f);
Miroslav Zagoraca75f3402021-09-09 10:31:12 +020098 struct buffer uuid;
Miroslav Zagorac70230c62020-12-09 16:54:31 +010099 struct flt_ot_runtime_context *retptr = NULL;
100
101 FLT_OT_FUNC("%p, %p, %p:%p", s, f, FLT_OT_DPTR_ARGS(err));
102
103 retptr = flt_ot_pool_alloc(pool_head_ot_runtime_context, sizeof(*retptr), 1, err);
104 if (retptr == NULL)
Miroslav Zagoracca09e012022-03-04 09:56:00 +0100105 FLT_OT_RETURN_PTR(retptr);
Miroslav Zagorac70230c62020-12-09 16:54:31 +0100106
107 retptr->stream = s;
108 retptr->filter = f;
Miroslav Zagorac70230c62020-12-09 16:54:31 +0100109 retptr->flag_harderr = conf->tracer->flag_harderr;
110 retptr->flag_disabled = conf->tracer->flag_disabled;
111 retptr->logging = conf->tracer->logging;
112 LIST_INIT(&(retptr->spans));
113 LIST_INIT(&(retptr->contexts));
114
Miroslav Zagoraca75f3402021-09-09 10:31:12 +0200115 uuid = b_make(retptr->uuid, sizeof(retptr->uuid), 0, 0);
116 ha_generate_uuid(&uuid);
Miroslav Zagorac70230c62020-12-09 16:54:31 +0100117
Miroslav Zagorac4cb2c832021-09-08 20:56:05 +0200118#ifdef USE_OT_VARS
119 /*
Miroslav Zagorac220a1ad2022-02-23 10:28:10 +0100120 * The HAProxy variable 'sess.ot.uuid' is registered here,
Miroslav Zagorac4cb2c832021-09-08 20:56:05 +0200121 * after which its value is set to runtime context UUID.
122 */
123 if (flt_ot_var_register(FLT_OT_VAR_UUID, err) != -1)
Miroslav Zagoraca75f3402021-09-09 10:31:12 +0200124 (void)flt_ot_var_set(s, FLT_OT_VAR_UUID, retptr->uuid, SMP_OPT_DIR_REQ, err);
Miroslav Zagorac4cb2c832021-09-08 20:56:05 +0200125#endif
Miroslav Zagorac70230c62020-12-09 16:54:31 +0100126
127 FLT_OT_DBG_RUNTIME_CONTEXT("session context: ", retptr);
128
Miroslav Zagoracca09e012022-03-04 09:56:00 +0100129 FLT_OT_RETURN_PTR(retptr);
Miroslav Zagorac70230c62020-12-09 16:54:31 +0100130}
131
132
133/***
134 * NAME
135 * flt_ot_runtime_context_free -
136 *
137 * ARGUMENTS
138 * f -
139 *
140 * DESCRIPTION
141 * -
142 *
143 * RETURN VALUE
144 * This function does not return a value.
145 */
146void flt_ot_runtime_context_free(struct filter *f)
147{
148 struct flt_ot_runtime_context *rt_ctx = f->ctx;
149
150 FLT_OT_FUNC("%p", f);
151
152 if (rt_ctx == NULL)
153 FLT_OT_RETURN();
154
155 FLT_OT_DBG_RUNTIME_CONTEXT("session context: ", rt_ctx);
156
157 if (!LIST_ISEMPTY(&(rt_ctx->spans))) {
158 struct timespec ts;
159 struct flt_ot_scope_span *span, *span_back;
160
161 /* All spans should be completed at the same time. */
162 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
163
164 list_for_each_entry_safe(span, span_back, &(rt_ctx->spans), list) {
165 ot_span_finish(&(span->span), &ts, NULL, NULL, NULL);
166 flt_ot_scope_span_free(&span);
167 }
168 }
169
170 if (!LIST_ISEMPTY(&(rt_ctx->contexts))) {
171 struct flt_ot_scope_context *ctx, *ctx_back;
172
173 list_for_each_entry_safe(ctx, ctx_back, &(rt_ctx->contexts), list)
174 flt_ot_scope_context_free(&ctx);
175 }
176
177 flt_ot_pool_free(pool_head_ot_runtime_context, &(f->ctx));
178
179 FLT_OT_RETURN();
180}
181
182
183/***
184 * NAME
185 * flt_ot_scope_span_init -
186 *
187 * ARGUMENTS
188 * rt_ctx -
189 * id -
190 * id_len -
191 * ref_type -
192 * ref_id -
193 * ref_id_len -
194 * dir -
195 * err -
196 *
197 * DESCRIPTION
198 * -
199 *
200 * RETURN VALUE
201 * -
202 */
203struct flt_ot_scope_span *flt_ot_scope_span_init(struct flt_ot_runtime_context *rt_ctx, const char *id, size_t id_len, otc_span_reference_type_t ref_type, const char *ref_id, size_t ref_id_len, uint dir, char **err)
204{
205 struct otc_span *ref_span = NULL;
206 struct otc_span_context *ref_ctx = NULL;
207 struct flt_ot_scope_span *span, *retptr = NULL;
208 struct flt_ot_scope_context *ctx;
209
210 FLT_OT_FUNC("%p, \"%s\", %zu, %d, \"%s\", %zu, %u, %p:%p", rt_ctx, id, id_len, ref_type, ref_id, ref_id_len, dir, FLT_OT_DPTR_ARGS(err));
211
212 if ((rt_ctx == NULL) || (id == NULL))
Miroslav Zagoracca09e012022-03-04 09:56:00 +0100213 FLT_OT_RETURN_PTR(retptr);
Miroslav Zagorac70230c62020-12-09 16:54:31 +0100214
215 list_for_each_entry(span, &(rt_ctx->spans), list)
216 if ((span->id_len == id_len) && (memcmp(span->id, id, id_len) == 0)) {
217 FLT_OT_DBG(2, "found span %p", span);
218
Miroslav Zagoracca09e012022-03-04 09:56:00 +0100219 FLT_OT_RETURN_PTR(span);
Miroslav Zagorac70230c62020-12-09 16:54:31 +0100220 }
221
222 if (ref_id != NULL) {
223 list_for_each_entry(span, &(rt_ctx->spans), list)
224 if ((span->id_len == ref_id_len) && (memcmp(span->id, ref_id, ref_id_len) == 0)) {
225 ref_span = span->span;
226
227 break;
228 }
229
230 if (ref_span != NULL) {
231 FLT_OT_DBG(2, "found referenced span %p", span);
232 } else {
233 list_for_each_entry(ctx, &(rt_ctx->contexts), list)
234 if ((ctx->id_len == ref_id_len) && (memcmp(ctx->id, ref_id, ref_id_len) == 0)) {
235 ref_ctx = ctx->context;
236
237 break;
238 }
239
240 if (ref_ctx != NULL) {
241 FLT_OT_DBG(2, "found referenced context %p", ctx);
242 } else {
243 FLT_OT_ERR("cannot find referenced span/context '%s'", ref_id);
244
Miroslav Zagoracca09e012022-03-04 09:56:00 +0100245 FLT_OT_RETURN_PTR(retptr);
Miroslav Zagorac70230c62020-12-09 16:54:31 +0100246 }
247 }
248 }
249
250 retptr = flt_ot_pool_alloc(pool_head_ot_scope_span, sizeof(*retptr), 1, err);
251 if (retptr == NULL)
Miroslav Zagoracca09e012022-03-04 09:56:00 +0100252 FLT_OT_RETURN_PTR(retptr);
Miroslav Zagorac70230c62020-12-09 16:54:31 +0100253
254 retptr->id = id;
255 retptr->id_len = id_len;
256 retptr->smp_opt_dir = dir;
257 retptr->ref_type = ref_type;
258 retptr->ref_span = ref_span;
259 retptr->ref_ctx = ref_ctx;
Willy Tarreau2b718102021-04-21 07:32:39 +0200260 LIST_INSERT(&(rt_ctx->spans), &(retptr->list));
Miroslav Zagorac70230c62020-12-09 16:54:31 +0100261
262 FLT_OT_DBG_SCOPE_SPAN("new span ", retptr);
263
Miroslav Zagoracca09e012022-03-04 09:56:00 +0100264 FLT_OT_RETURN_PTR(retptr);
Miroslav Zagorac70230c62020-12-09 16:54:31 +0100265}
266
267
268/***
269 * NAME
270 * flt_ot_scope_span_free -
271 *
272 * ARGUMENTS
273 * ptr -
274 *
275 * DESCRIPTION
276 * -
277 *
278 * RETURN VALUE
279 * This function does not return a value.
280 */
281void flt_ot_scope_span_free(struct flt_ot_scope_span **ptr)
282{
283 FLT_OT_FUNC("%p:%p", FLT_OT_DPTR_ARGS(ptr));
284
285 if ((ptr == NULL) || (*ptr == NULL))
286 FLT_OT_RETURN();
287
288 FLT_OT_DBG_SCOPE_SPAN("", *ptr);
289
290 /* If the span is still active, do nothing. */
291 if ((*ptr)->span != NULL) {
292 FLT_OT_DBG(2, "cannot finish active span");
293
294 FLT_OT_RETURN();
295 }
296
297 FLT_OT_LIST_DEL(&((*ptr)->list));
298 flt_ot_pool_free(pool_head_ot_scope_span, (void **)ptr);
299
300 FLT_OT_RETURN();
301}
302
303
304/***
305 * NAME
306 * flt_ot_scope_context_init -
307 *
308 * ARGUMENTS
309 * rt_ctx -
310 * tracer -
311 * id -
312 * id_len -
313 * text_map -
314 * dir -
315 * err -
316 *
317 * DESCRIPTION
318 * -
319 *
320 * RETURN VALUE
321 * -
322 */
323struct flt_ot_scope_context *flt_ot_scope_context_init(struct flt_ot_runtime_context *rt_ctx, struct otc_tracer *tracer, const char *id, size_t id_len, const struct otc_text_map *text_map, uint dir, char **err)
324{
325 struct otc_http_headers_reader reader;
326 struct otc_span_context *span_ctx;
327 struct flt_ot_scope_context *retptr = NULL;
328
329 FLT_OT_FUNC("%p, %p, \"%s\", %zu, %p, %u, %p:%p", rt_ctx, tracer, id, id_len, text_map, dir, FLT_OT_DPTR_ARGS(err));
330
331 if ((rt_ctx == NULL) || (tracer == NULL) || (id == NULL) || (text_map == NULL))
Miroslav Zagoracca09e012022-03-04 09:56:00 +0100332 FLT_OT_RETURN_PTR(retptr);
Miroslav Zagorac70230c62020-12-09 16:54:31 +0100333
334 list_for_each_entry(retptr, &(rt_ctx->contexts), list)
335 if ((retptr->id_len == id_len) && (memcmp(retptr->id, id, id_len) == 0)) {
336 FLT_OT_DBG(2, "found context %p", retptr);
337
Miroslav Zagoracca09e012022-03-04 09:56:00 +0100338 FLT_OT_RETURN_PTR(retptr);
Miroslav Zagorac70230c62020-12-09 16:54:31 +0100339 }
340
341 retptr = flt_ot_pool_alloc(pool_head_ot_scope_context, sizeof(*retptr), 1, err);
342 if (retptr == NULL)
Miroslav Zagoracca09e012022-03-04 09:56:00 +0100343 FLT_OT_RETURN_PTR(retptr);
Miroslav Zagorac70230c62020-12-09 16:54:31 +0100344
345 span_ctx = ot_extract_http_headers(tracer, &reader, text_map, err);
346 if (span_ctx == NULL) {
347 flt_ot_scope_context_free(&retptr);
348
Miroslav Zagoracca09e012022-03-04 09:56:00 +0100349 FLT_OT_RETURN_PTR(retptr);
Miroslav Zagorac70230c62020-12-09 16:54:31 +0100350 }
351
352 retptr->id = id;
353 retptr->id_len = id_len;
354 retptr->smp_opt_dir = dir;
355 retptr->context = span_ctx;
Willy Tarreau2b718102021-04-21 07:32:39 +0200356 LIST_INSERT(&(rt_ctx->contexts), &(retptr->list));
Miroslav Zagorac70230c62020-12-09 16:54:31 +0100357
358 FLT_OT_DBG_SCOPE_CONTEXT("new context ", retptr);
359
Miroslav Zagoracca09e012022-03-04 09:56:00 +0100360 FLT_OT_RETURN_PTR(retptr);
Miroslav Zagorac70230c62020-12-09 16:54:31 +0100361}
362
363
364/***
365 * NAME
366 * flt_ot_scope_context_free -
367 *
368 * ARGUMENTS
369 * ptr -
370 *
371 * DESCRIPTION
372 * -
373 *
374 * RETURN VALUE
375 * This function does not return a value.
376 */
377void flt_ot_scope_context_free(struct flt_ot_scope_context **ptr)
378{
379 FLT_OT_FUNC("%p:%p", FLT_OT_DPTR_ARGS(ptr));
380
381 if ((ptr == NULL) || (*ptr == NULL))
382 FLT_OT_RETURN();
383
384 FLT_OT_DBG_SCOPE_CONTEXT("", *ptr);
385
386 if ((*ptr)->context != NULL)
387 (*ptr)->context->destroy(&((*ptr)->context));
388
389 FLT_OT_LIST_DEL(&((*ptr)->list));
390 flt_ot_pool_free(pool_head_ot_scope_context, (void **)ptr);
391
392 FLT_OT_RETURN();
393}
394
395
396/***
397 * NAME
398 * flt_ot_scope_data_free -
399 *
400 * ARGUMENTS
401 * ptr -
402 *
403 * DESCRIPTION
404 * -
405 *
406 * RETURN VALUE
407 * This function does not return a value.
408 */
409void flt_ot_scope_data_free(struct flt_ot_scope_data *ptr)
410{
411 int i;
412
413 FLT_OT_FUNC("%p", ptr);
414
415 if (ptr == NULL)
416 FLT_OT_RETURN();
417
418 FLT_OT_DBG_SCOPE_DATA("", ptr);
419
420 for (i = 0; i < ptr->num_tags; i++)
421 if (ptr->tags[i].value.type == otc_value_string)
422 FLT_OT_FREE_VOID(ptr->tags[i].value.value.string_value);
423 otc_text_map_destroy(&(ptr->baggage), OTC_TEXT_MAP_FREE_VALUE);
424 for (i = 0; i < ptr->num_log_fields; i++)
425 if (ptr->log_fields[i].value.type == otc_value_string)
426 FLT_OT_FREE_VOID(ptr->log_fields[i].value.value.string_value);
427
428 (void)memset(ptr, 0, sizeof(*ptr));
429
430 FLT_OT_RETURN();
431}
432
433
434/***
435 * NAME
436 * flt_ot_scope_finish_mark -
437 *
438 * ARGUMENTS
439 * rt_ctx -
440 * id -
441 * id_len -
442 *
443 * DESCRIPTION
444 * -
445 *
446 * RETURN VALUE
447 * -
448 */
449int flt_ot_scope_finish_mark(const struct flt_ot_runtime_context *rt_ctx, const char *id, size_t id_len)
450{
451 struct flt_ot_scope_span *span;
452 struct flt_ot_scope_context *ctx;
453 int span_cnt = 0, ctx_cnt = 0, retval;
454
455 FLT_OT_FUNC("%p, \"%s\", %zu", rt_ctx, id, id_len);
456
457 if (FLT_OT_STR_CMP(FLT_OT_SCOPE_SPAN_FINISH_ALL, id, id_len)) {
458 list_for_each_entry(span, &(rt_ctx->spans), list) {
459 span->flag_finish = 1;
460 span_cnt++;
461 }
462
463 list_for_each_entry(ctx, &(rt_ctx->contexts), list) {
464 ctx->flag_finish = 1;
465 ctx_cnt++;
466 }
467
468 FLT_OT_DBG(2, "marked %d span(s), %d context(s)", span_cnt, ctx_cnt);
469 }
470 else if (FLT_OT_STR_CMP(FLT_OT_SCOPE_SPAN_FINISH_REQ, id, id_len)) {
471 list_for_each_entry(span, &(rt_ctx->spans), list)
472 if (span->smp_opt_dir == SMP_OPT_DIR_REQ) {
473 span->flag_finish = 1;
474 span_cnt++;
475 }
476
477 list_for_each_entry(ctx, &(rt_ctx->contexts), list)
478 if (ctx->smp_opt_dir == SMP_OPT_DIR_REQ) {
479 ctx->flag_finish = 1;
480 span_cnt++;
481 }
482
483 FLT_OT_DBG(2, "marked REQuest channel %d span(s), %d context(s)", span_cnt, ctx_cnt);
484 }
485 else if (FLT_OT_STR_CMP(FLT_OT_SCOPE_SPAN_FINISH_RES, id, id_len)) {
486 list_for_each_entry(span, &(rt_ctx->spans), list)
487 if (span->smp_opt_dir == SMP_OPT_DIR_RES) {
488 span->flag_finish = 1;
489 span_cnt++;
490 }
491
492 list_for_each_entry(ctx, &(rt_ctx->contexts), list)
493 if (ctx->smp_opt_dir == SMP_OPT_DIR_RES) {
494 ctx->flag_finish = 1;
495 ctx_cnt++;
496 }
497
498 FLT_OT_DBG(2, "marked RESponse channel %d span(s), %d context(s)", span_cnt, ctx_cnt);
499 }
500 else {
501 list_for_each_entry(span, &(rt_ctx->spans), list)
502 if ((span->id_len == id_len) && (memcmp(span->id, id, id_len) == 0)) {
503 span->flag_finish = 1;
504 span_cnt++;
505
506 break;
507 }
508
509 list_for_each_entry(ctx, &(rt_ctx->contexts), list)
510 if ((ctx->id_len == id_len) && (memcmp(ctx->id, id, id_len) == 0)) {
511 ctx->flag_finish = 1;
512 ctx_cnt++;
513
514 break;
515 }
516
517 if (span_cnt > 0)
518 FLT_OT_DBG(2, "marked span '%s'", id);
519 if (ctx_cnt > 0)
520 FLT_OT_DBG(2, "marked context '%s'", id);
521 if ((span_cnt + ctx_cnt) == 0)
522 FLT_OT_DBG(2, "cannot find span/context '%s'", id);
523 }
524
525 retval = span_cnt + ctx_cnt;
526
Miroslav Zagoracca09e012022-03-04 09:56:00 +0100527 FLT_OT_RETURN_INT(retval);
Miroslav Zagorac70230c62020-12-09 16:54:31 +0100528}
529
530
531/***
532 * NAME
533 * flt_ot_scope_finish_marked -
534 *
535 * ARGUMENTS
536 * rt_ctx -
537 * ts_finish -
538 *
539 * DESCRIPTION
540 * Finish marked spans.
541 *
542 * RETURN VALUE
543 * This function does not return a value.
544 */
545void flt_ot_scope_finish_marked(const struct flt_ot_runtime_context *rt_ctx, const struct timespec *ts_finish)
546{
547 struct flt_ot_scope_span *span;
548 struct flt_ot_scope_context *ctx;
549
550 FLT_OT_FUNC("%p, %p", rt_ctx, ts_finish);
551
552 list_for_each_entry(span, &(rt_ctx->spans), list)
553 if (span->flag_finish) {
554 FLT_OT_DBG_SCOPE_SPAN("finishing span ", span);
555
556 ot_span_finish(&(span->span), ts_finish, NULL, NULL, NULL);
557
558 span->flag_finish = 0;
559 }
560
561 list_for_each_entry(ctx, &(rt_ctx->contexts), list)
562 if (ctx->flag_finish) {
563 FLT_OT_DBG_SCOPE_CONTEXT("finishing context ", ctx);
564
565 if (ctx->context != NULL)
566 ctx->context->destroy(&(ctx->context));
567
568 ctx->flag_finish = 0;
569 }
570
571 FLT_OT_RETURN();
572}
573
574
575/***
576 * NAME
577 * flt_ot_scope_free_unused -
578 *
579 * ARGUMENTS
580 * rt_ctx -
581 * chn -
582 *
583 * DESCRIPTION
584 * -
585 *
586 * RETURN VALUE
587 * This function does not return a value.
588 */
589void flt_ot_scope_free_unused(struct flt_ot_runtime_context *rt_ctx, struct channel *chn)
590{
591 FLT_OT_FUNC("%p", rt_ctx);
592
593 if (rt_ctx == NULL)
594 FLT_OT_RETURN();
595
596 if (!LIST_ISEMPTY(&(rt_ctx->spans))) {
597 struct flt_ot_scope_span *span, *span_back;
598
599 list_for_each_entry_safe(span, span_back, &(rt_ctx->spans), list)
600 if (span->span == NULL)
601 flt_ot_scope_span_free(&span);
602 }
603
604 if (!LIST_ISEMPTY(&(rt_ctx->contexts))) {
605 struct flt_ot_scope_context *ctx, *ctx_back;
606
607 list_for_each_entry_safe(ctx, ctx_back, &(rt_ctx->contexts), list)
608 if (ctx->context == NULL) {
609 /*
610 * All headers and variables associated with
611 * the context in question should be deleted.
612 */
613 (void)flt_ot_http_headers_remove(chn, ctx->id, NULL);
Miroslav Zagorac4cb2c832021-09-08 20:56:05 +0200614#ifdef USE_OT_VARS
Miroslav Zagorac70230c62020-12-09 16:54:31 +0100615 (void)flt_ot_vars_unset(rt_ctx->stream, FLT_OT_VARS_SCOPE, ctx->id, ctx->smp_opt_dir, NULL);
Miroslav Zagorac4cb2c832021-09-08 20:56:05 +0200616#endif
Miroslav Zagorac70230c62020-12-09 16:54:31 +0100617
618 flt_ot_scope_context_free(&ctx);
619 }
620 }
621
622 FLT_OT_DBG_RUNTIME_CONTEXT("session context: ", rt_ctx);
623
624 FLT_OT_RETURN();
625}
626
627/*
628 * Local variables:
629 * c-indent-level: 8
630 * c-basic-offset: 8
631 * End:
632 *
633 * vi: noexpandtab shiftwidth=8 tabstop=8
634 */