| | varnish-cache/bin/varnishd/http2/cache_http2_panic.c |
| 0 |
|
/*- |
| 1 |
|
* Copyright (c) 2016 Varnish Software AS |
| 2 |
|
* All rights reserved. |
| 3 |
|
* |
| 4 |
|
* Author: Poul-Henning Kamp <phk@phk.freebsd.dk> |
| 5 |
|
* |
| 6 |
|
* SPDX-License-Identifier: BSD-2-Clause |
| 7 |
|
* |
| 8 |
|
* Redistribution and use in source and binary forms, with or without |
| 9 |
|
* modification, are permitted provided that the following conditions |
| 10 |
|
* are met: |
| 11 |
|
* 1. Redistributions of source code must retain the above copyright |
| 12 |
|
* notice, this list of conditions and the following disclaimer. |
| 13 |
|
* 2. Redistributions in binary form must reproduce the above copyright |
| 14 |
|
* notice, this list of conditions and the following disclaimer in the |
| 15 |
|
* documentation and/or other materials provided with the distribution. |
| 16 |
|
* |
| 17 |
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
| 18 |
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 19 |
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 20 |
|
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE |
| 21 |
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 22 |
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 23 |
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 24 |
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 25 |
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 26 |
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 27 |
|
* SUCH DAMAGE. |
| 28 |
|
* |
| 29 |
|
*/ |
| 30 |
|
|
| 31 |
|
#include "config.h" |
| 32 |
|
|
| 33 |
|
#include <stdint.h> |
| 34 |
|
|
| 35 |
|
#include "cache/cache_varnishd.h" |
| 36 |
|
|
| 37 |
|
#include "cache/cache_transport.h" |
| 38 |
|
#include "http2/cache_http2.h" |
| 39 |
|
|
| 40 |
|
static const char * |
| 41 |
90 |
h2_panic_error(const struct h2_error_s *e) |
| 42 |
60 |
{ |
| 43 |
90 |
if (e == NULL) |
| 44 |
90 |
return ("(null)"); |
| 45 |
|
else |
| 46 |
0 |
return (e->name); |
| 47 |
90 |
} |
| 48 |
|
|
| 49 |
|
static void |
| 50 |
60 |
h2_panic_settings(struct vsb *vsb, const struct h2_settings *s) |
| 51 |
|
{ |
| 52 |
60 |
int cont = 0; |
| 53 |
60 |
|
| 54 |
|
#define H2_SETTING(U,l,...) \ |
| 55 |
|
do { \ |
| 56 |
|
if (cont) \ |
| 57 |
|
VSB_printf(vsb, ", "); \ |
| 58 |
|
cont = 1; \ |
| 59 |
|
VSB_printf(vsb, "0x%x", s->l); \ |
| 60 |
|
} while (0); |
| 61 |
|
#include "tbl/h2_settings.h" |
| 62 |
|
#undef H2_SETTING |
| 63 |
|
} |
| 64 |
60 |
|
| 65 |
|
void |
| 66 |
30 |
h2_sess_panic(struct vsb *vsb, const struct sess *sp) |
| 67 |
|
{ |
| 68 |
|
uintptr_t *up; |
| 69 |
|
struct h2_sess *h2; |
| 70 |
|
struct h2_req *r2; |
| 71 |
|
|
| 72 |
30 |
AZ(SES_Get_proto_priv(sp, &up)); |
| 73 |
|
|
| 74 |
90 |
AN(up); |
| 75 |
30 |
h2 = (void*)*up; |
| 76 |
30 |
if (PAN_dump_struct(vsb, h2, H2_SESS_MAGIC, "h2_sess")) |
| 77 |
0 |
return; |
| 78 |
60 |
VSB_printf(vsb, "refcnt = %d, bogosity = %d, error = %s\n", |
| 79 |
30 |
h2->refcnt, h2->bogosity, h2_panic_error(h2->error)); |
| 80 |
60 |
VSB_printf(vsb, |
| 81 |
|
"open_streams = %d, highest_stream = %u," |
| 82 |
|
" goaway_last_stream = %u,\n", |
| 83 |
30 |
h2->open_streams, h2->highest_stream, h2->goaway_last_stream); |
| 84 |
90 |
VSB_cat(vsb, "local_settings = {"); |
| 85 |
30 |
h2_panic_settings(vsb, &h2->local_settings); |
| 86 |
30 |
VSB_cat(vsb, "},\n"); |
| 87 |
30 |
VSB_cat(vsb, "remote_settings = {"); |
| 88 |
30 |
h2_panic_settings(vsb, &h2->remote_settings); |
| 89 |
30 |
VSB_cat(vsb, "},\n"); |
| 90 |
60 |
VSB_printf(vsb, |
| 91 |
|
"{rxf_len, rxf_type, rxf_flags, rxf_stream} =" |
| 92 |
|
" {%u, %u, 0x%x, %u},\n", |
| 93 |
30 |
h2->rxf_len, h2->rxf_type, h2->rxf_flags, h2->rxf_stream); |
| 94 |
90 |
VTAILQ_FOREACH(r2, &h2->streams, list) { |
| 95 |
120 |
if (PAN_dump_struct(vsb, r2, H2_REQ_MAGIC, "stream")) |
| 96 |
0 |
continue; |
| 97 |
60 |
VSB_printf(vsb, "id = %u, state = ", r2->stream); |
| 98 |
60 |
switch (r2->state) { |
| 99 |
|
#define H2_STREAM(U,sd,d) case H2_S_##U: VSB_printf(vsb, "%s", sd); break; |
| 100 |
|
#include <tbl/h2_stream.h> |
| 101 |
|
default: |
| 102 |
|
VSB_printf(vsb, " 0x%x", r2->state); |
| 103 |
|
break; |
| 104 |
|
} |
| 105 |
120 |
VSB_cat(vsb, ",\n"); |
| 106 |
|
|
| 107 |
120 |
VSB_printf(vsb, "h2_sess = %p, scheduled = %d, error = %s,\n", |
| 108 |
60 |
r2->h2sess, r2->scheduled, h2_panic_error(r2->error)); |
| 109 |
120 |
VSB_printf(vsb, "t_send = %f, t_winupd = %f,\n", |
| 110 |
60 |
r2->t_send, r2->t_winupd); |
| 111 |
120 |
VSB_printf(vsb, "t_window = %jd, r_window = %jd,\n", |
| 112 |
60 |
(intmax_t)r2->t_window, (intmax_t)r2->r_window); |
| 113 |
|
|
| 114 |
60 |
if (!PAN_dump_struct(vsb, r2->rxbuf, H2_RXBUF_MAGIC, "rxbuf")) { |
| 115 |
60 |
VSB_printf(vsb, "stvbuf = %p,\n", r2->rxbuf->stvbuf); |
| 116 |
0 |
VSB_printf(vsb, |
| 117 |
|
"{size, tail, head} = {%u, %ju, %ju},\n", |
| 118 |
0 |
r2->rxbuf->size, (uintmax_t)r2->rxbuf->tail, |
| 119 |
0 |
(uintmax_t)r2->rxbuf->head); |
| 120 |
0 |
VSB_indent(vsb, -2); |
| 121 |
0 |
VSB_cat(vsb, "},\n"); |
| 122 |
0 |
} |
| 123 |
|
|
| 124 |
60 |
VSB_indent(vsb, -2); |
| 125 |
120 |
VSB_cat(vsb, "},\n"); |
| 126 |
60 |
} |
| 127 |
30 |
VSB_indent(vsb, -2); |
| 128 |
30 |
} |