Commit d5a8bac1 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

un-inline a couple of enum-to-string functions

parent 09939bc4
......@@ -54,7 +54,6 @@
#include <sys/epoll.h>
#endif
#include "common/params.h"
/*--------------------------------------------------------------------*/
......@@ -73,18 +72,6 @@ enum body_status {
#undef BODYSTATUS
};
static inline const char *
body_status(enum body_status e)
{
switch(e) {
#define BODYSTATUS(U,l) case BS_##U: return (#l);
#include "tbl/body_status.h"
#undef BODYSTATUS
default:
return ("?");
}
}
/*--------------------------------------------------------------------*/
enum req_body_state_e {
......@@ -102,19 +89,6 @@ enum sess_close {
#undef SESS_CLOSE
};
static inline const char *
sess_close_str(enum sess_close sc, int want_desc)
{
switch (sc) {
case SC_NULL: return(want_desc ? "(null)": "NULL");
#define SESS_CLOSE(nm, desc) case SC_##nm: return(want_desc ? desc : #nm);
#include "tbl/sess_close.h"
#undef SESS_CLOSE
default: return(want_desc ? "(invalid)" : "INVALID");
}
}
/*--------------------------------------------------------------------*/
/*
......@@ -129,6 +103,8 @@ enum {
#undef SLTH
};
/*--------------------------------------------------------------------*/
struct SHA256Context;
struct VSC_C_lck;
struct ban;
......@@ -960,6 +936,8 @@ void MPL_Free(struct mempool *mpl, void *item);
/* cache_panic.c */
void PAN_Init(void);
const char *body_status_2str(enum body_status e);
const char *sess_close_2str(enum sess_close sc, int want_desc);
/* cache_pipe.c */
void PipeRequest(struct req *req);
......
......@@ -611,7 +611,7 @@ FetchBody(struct worker *wrk, void *priv)
bo->vfp = NULL;
VSLb(bo->vsl, SLT_Fetch_Body, "%u(%s) cls %d mklen %d",
htc->body_status, body_status(htc->body_status),
htc->body_status, body_status_2str(htc->body_status),
cls, mklen);
http_Teardown(bo->bereq);
......
......@@ -61,6 +61,35 @@ static void pan_sess(const struct sess *sp);
/*--------------------------------------------------------------------*/
const char *
body_status_2str(enum body_status e)
{
switch(e) {
#define BODYSTATUS(U,l) case BS_##U: return (#l);
#include "tbl/body_status.h"
#undef BODYSTATUS
default:
return ("?");
}
}
/*--------------------------------------------------------------------*/
const char *
sess_close_2str(enum sess_close sc, int want_desc)
{
switch (sc) {
case SC_NULL: return(want_desc ? "(null)": "NULL");
#define SESS_CLOSE(nm, desc) case SC_##nm: return(want_desc ? desc : #nm);
#include "tbl/sess_close.h"
#undef SESS_CLOSE
default: return(want_desc ? "(invalid)" : "INVALID");
}
}
/*--------------------------------------------------------------------*/
static void
pan_ws(const struct ws *ws, int indent)
{
......@@ -216,7 +245,7 @@ pan_busyobj(const struct busyobj *bo)
if (bo->do_stream) VSB_printf(pan_vsp, " do_stream\n");
if (bo->should_close) VSB_printf(pan_vsp, " should_close\n");
VSB_printf(pan_vsp, " bodystatus = %d (%s),\n",
bo->htc.body_status, body_status(bo->htc.body_status));
bo->htc.body_status, body_status_2str(bo->htc.body_status));
VSB_printf(pan_vsp, " },\n");
if (VALID_OBJ(bo->vbc, BACKEND_MAGIC))
pan_vbc(bo->vbc);
......
......@@ -327,7 +327,7 @@ SES_Delete(struct sess *sp, enum sess_close reason, double now)
b = &sp->acct_ses;
VSL(SLT_SessClose, sp->vxid, "%s %.3f %ju %ju %ju %ju %ju %ju",
sess_close_str(sp->reason, 0), now - sp->t_open, b->req,
sess_close_2str(sp->reason, 0), now - sp->t_open, b->req,
b->pipe, b->pass, b->fetch, b->hdrbytes, b->bodybytes);
MPL_Free(pp->mpl_sess, sp);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment