Skip to content

Instantly share code, notes, and snippets.

@tksst
Last active August 6, 2021 14:50
Show Gist options
  • Save tksst/a3fcb4bd28bda67306eec97bfc7263ea to your computer and use it in GitHub Desktop.
Save tksst/a3fcb4bd28bda67306eec97bfc7263ea to your computer and use it in GitHub Desktop.
typedef struct
{
char *str;
conn_rec *c;
} dump_conn_notes_ctx;
static int foo(void *rec, const char *key, const char *value)
{
dump_conn_notes_ctx *v = rec;
v->str = apr_pstrcat(v->c->pool, v->str, key, ": ", value, ",", NULL);
return 1;
}
static char *dump_conn_notes(conn_rec *c)
{
dump_conn_notes_ctx *v = apr_palloc(c->pool, sizeof(*v));
v->c = c;
v->str = apr_pstrdup(c->pool, "{");
apr_table_do(foo, v, c->notes, NULL);
return apr_pstrcat(c->pool, v->str, "}", NULL);
}
static char *dump_conn_rec(conn_rec *c)
{
const char *cs_str = NULL;
if (!c->cs)
{
cs_str = "NULL";
}
else
{
cs_str = apr_psprintf(c->pool, "{ state: %d, sense: %d }", c->cs->state, c->cs->sense);
}
return apr_psprintf(c->pool,
"{ local_addr_port: %d, client_addr_port: %d, id: %ld, conn_config: %lx, sbh: %lx, cs: %s, clogging_input_filters: %u, aborted: %u, keepalive: %d, keepalives: %d, log_id: %s }",
(int)c->local_addr->port, (int)c->client_addr->port,
c->id, c->conn_config, c->sbh,
cs_str, c->clogging_input_filters,
c->aborted, c->keepalive, c->keepalives, c->log_id);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment