Commit ad65eb54 authored by Martin Blix Grydeland's avatar Martin Blix Grydeland
parents 673c50de 0008c89e
......@@ -75,6 +75,30 @@ body_status(enum body_status e)
}
}
/*--------------------------------------------------------------------*/
enum sess_close {
SC_NULL = 0,
#define SESS_CLOSE(nm, desc) SC_##nm,
#include "tbl/sess_close.h"
#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");
}
}
/*--------------------------------------------------------------------*/
/*
* NB: HDR_STATUS is only used in cache_http.c, everybody else uses the
* http->status integer field.
......@@ -585,7 +609,7 @@ struct req {
unsigned char digest[DIGEST_LEN];
const char *doclose;
enum sess_close doclose;
struct exp exp;
unsigned cur_method;
unsigned handling;
......@@ -655,6 +679,7 @@ struct sess {
enum sess_step sess_step;
int fd;
enum sess_close reason;
unsigned vsl_id;
uint32_t vxid;
......@@ -840,7 +865,7 @@ const char *http_GetReq(const struct http *hp);
int http_HdrIs(const struct http *hp, const char *hdr, const char *val);
uint16_t http_DissectRequest(struct req *);
uint16_t http_DissectResponse(struct http *sp, const struct http_conn *htc);
const char *http_DoConnection(const struct http *hp);
enum sess_close http_DoConnection(const struct http *);
void http_CopyHome(const struct http *hp);
void http_Unset(struct http *hp, const char *hdr);
void http_CollectHdr(struct http *hp, const char *hdr);
......@@ -919,8 +944,8 @@ unsigned WRW_Write(const struct worker *w, const void *ptr, int len);
unsigned WRW_WriteH(const struct worker *w, const txt *hh, const char *suf);
/* cache_session.c [SES] */
void SES_Close(struct sess *sp, const char *reason);
void SES_Delete(struct sess *sp, const char *reason, double now);
void SES_Close(struct sess *sp, enum sess_close reason);
void SES_Delete(struct sess *sp, enum sess_close reason, double now);
void SES_Charge(struct worker *, struct req *);
struct sesspool *SES_NewPool(struct pool *pp, unsigned pool_no);
void SES_DeletePool(struct sesspool *sp);
......
......@@ -109,7 +109,7 @@ cnt_wait(struct sess *sp, struct worker *wrk, struct req *req)
int i, j, tmo;
struct pollfd pfd[1];
double now, when;
const char *why = NULL;
enum sess_close why = SC_NULL;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
......@@ -143,16 +143,16 @@ cnt_wait(struct sess *sp, struct worker *wrk, struct req *req)
req->t_req = now;
return (0);
} else if (i == -1) {
why = "EOF";
why = SC_REM_CLOSE;
break;
} else if (i == -2) {
why = "overflow";
why = SC_RX_OVERFLOW;
break;
} else if (i == -3) {
/* Nothing but whitespace */
when = sp->t_idle + cache_param->timeout_idle;
if (when < now) {
why = "timeout";
why = SC_RX_TIMEOUT;
break;
}
when = sp->t_idle + cache_param->timeout_linger;
......@@ -170,7 +170,7 @@ cnt_wait(struct sess *sp, struct worker *wrk, struct req *req)
when = sp->t_rx + cache_param->timeout_req;
tmo = (int)(1e3 * (when - now));
if (when < now || tmo == 0) {
why = "req timeout";
why = SC_RX_TIMEOUT;
break;
}
}
......@@ -255,7 +255,7 @@ cnt_sess_done(struct sess *sp, struct worker *wrk, struct req *req)
req->hash_always_miss = 0;
req->hash_ignore_busy = 0;
if (sp->fd >= 0 && req->doclose != NULL) {
if (sp->fd >= 0 && req->doclose != SC_NULL) {
/*
* This is an orderly close of the connection; ditch nolinger
* before we close, to get queued data transmitted.
......@@ -268,7 +268,7 @@ cnt_sess_done(struct sess *sp, struct worker *wrk, struct req *req)
wrk->stats.sess_closed++;
AZ(req->vcl);
SES_ReleaseReq(req);
SES_Delete(sp, NULL, NAN);
SES_Delete(sp, SC_NULL, NAN);
return (SESS_DONE_RET_GONE);
}
......@@ -318,9 +318,9 @@ CNT_Session(struct worker *wrk, struct req *req)
*/
if (sp->sess_step == S_STP_NEWREQ && VTCP_blocking(sp->fd)) {
if (errno == ECONNRESET)
SES_Close(sp, "remote closed");
SES_Close(sp, SC_REM_CLOSE);
else
SES_Close(sp, "error");
SES_Close(sp, SC_TX_ERROR);
sdr = cnt_sess_done(sp, wrk, req);
assert(sdr == SESS_DONE_RET_GONE);
return;
......@@ -437,7 +437,7 @@ cnt_prepresp(struct worker *wrk, struct req *req)
req->res_mode |= RES_CHUNKED;
} else {
req->res_mode |= RES_EOF;
req->doclose = "EOF mode";
req->doclose = SC_TX_EOF;
}
}
......@@ -573,7 +573,7 @@ cnt_error(struct worker *wrk, struct req *req)
(uint16_t)cache_param->http_max_hdr);
bo->stats = NULL;
if (req->obj == NULL) {
req->doclose = "Out of objects";
req->doclose = SC_OVERLOAD;
req->director = NULL;
http_Teardown(bo->beresp);
http_Teardown(bo->bereq);
......@@ -611,7 +611,7 @@ cnt_error(struct worker *wrk, struct req *req)
/* We always close when we take this path */
req->doclose = "error";
req->doclose = SC_TX_ERROR;
req->wantbody = 1;
assert(req->handling == VCL_RET_DELIVER);
......@@ -1504,7 +1504,7 @@ cnt_start(struct worker *wrk, struct req *req)
/* If we could not even parse the request, just close */
if (req->err_code == 400) {
SES_Close(req->sp, "junk");
SES_Close(req->sp, SC_RX_JUNK);
return (1);
}
......@@ -1520,7 +1520,7 @@ cnt_start(struct worker *wrk, struct req *req)
if (strcasecmp(p, "100-continue")) {
req->err_code = 417;
} else if (strlen(r) != write(req->sp->fd, r, strlen(r))) {
SES_Close(req->sp, "remote closed");
SES_Close(req->sp, SC_REM_CLOSE);
return (1);
}
}
......
......@@ -325,7 +325,7 @@ ESI_Deliver(struct req *req)
st->ptr + off, l2);
if (WRW_Error(req->wrk)) {
SES_Close(req->sp,
"remote closed");
SC_REM_CLOSE);
p = e;
break;
}
......@@ -376,7 +376,7 @@ ESI_Deliver(struct req *req)
if (vgz != NULL)
VGZ_WrwFlush(req->wrk, vgz);
if (WRW_Flush(req->wrk)) {
SES_Close(req->sp, "remote closed");
SES_Close(req->sp, SC_REM_CLOSE);
p = e;
break;
}
......
......@@ -410,19 +410,19 @@ http_GetHdrField(const struct http *hp, const char *hdr,
* XXX: redo with http_GetHdrField() ?
*/
const char *
enum sess_close
http_DoConnection(const struct http *hp)
{
char *p, *q;
const char *ret;
enum sess_close ret;
unsigned u;
if (!http_GetHdr(hp, H_Connection, &p)) {
if (hp->protover < 11)
return ("not HTTP/1.1");
return (NULL);
return (SC_REQ_HTTP10);
return (SC_NULL);
}
ret = NULL;
ret = SC_NULL;
AN(p);
for (; *p; p++) {
if (vct_issp(*p))
......@@ -434,7 +434,7 @@ http_DoConnection(const struct http *hp)
break;
u = pdiff(p, q);
if (u == 5 && !strncasecmp(p, "close", u))
ret = "Connection: close";
ret = SC_REQ_CLOSE;
u = http_findhdr(hp, u, p);
if (u != 0)
hp->hdf[u] |= HDF_FILTER;
......
......@@ -92,7 +92,7 @@ PipeRequest(struct req *req)
i = WRW_FlushRelease(wrk);
if (i) {
SES_Close(req->sp, "pipe");
SES_Close(req->sp, SC_TX_PIPE);
VDI_CloseFd(&vc);
return;
}
......@@ -132,7 +132,7 @@ PipeRequest(struct req *req)
fds[1].fd = -1;
}
}
SES_Close(req->sp, "pipe");
SES_Close(req->sp, SC_TX_PIPE);
VDI_CloseFd(&vc);
bo->vbc = NULL;
}
......@@ -285,5 +285,5 @@ RES_WriteObj(struct req *req)
WRW_EndChunk(req->wrk);
if (WRW_FlushRelease(req->wrk) && req->sp->fd >= 0)
SES_Close(req->sp, "remote closed");
SES_Close(req->sp, SC_REM_CLOSE);
}
......@@ -175,7 +175,7 @@ ses_vsl_socket(struct sess *sp, const char *lsockname)
strcpy(laddr, "-");
strcpy(lport, "-");
}
VSL(SLT_SessionOpen, sp->vxid, "%s %s %s %s %s",
VSL(SLT_SessOpen, sp->vxid, "%s %s %s %s %s",
sp->addr, sp->port, lsockname, laddr, lport);
}
......@@ -203,6 +203,7 @@ SES_pool_accept_task(struct worker *wrk, void *arg)
VCA_FailSess(wrk);
return;
}
wrk->acct_tmp.sess++;
sp->t_open = VTIM_real();
sp->t_rx = sp->t_open;
......@@ -217,9 +218,6 @@ SES_pool_accept_task(struct worker *wrk, void *arg)
req->vxid = VXID_Get(&wrk->vxid_pool);
wrk->acct_tmp.sess++;
sp->sess_step = S_STP_NEWREQ;
ses_pool_task(wrk, req);
}
......@@ -249,7 +247,7 @@ SES_ScheduleReq(struct req *req)
sp->t_idle = VTIM_real();
AN (req->vcl);
VCL_Rel(&req->vcl);
SES_Delete(sp, "dropped", sp->t_idle);
SES_Delete(sp, SC_OVERLOAD, sp->t_idle);
return (1);
}
return (0);
......@@ -282,7 +280,7 @@ SES_Handle(struct sess *sp, double now)
if (Pool_Task(pp->pool, &sp->task, POOL_QUEUE_FRONT)) {
VSC_C_main->client_drop_late++;
sp->t_idle = VTIM_real();
SES_Delete(sp, "dropped", sp->t_idle);
SES_Delete(sp, SC_OVERLOAD, sp->t_idle);
}
}
......@@ -293,12 +291,12 @@ SES_Handle(struct sess *sp, double now)
*/
void
SES_Close(struct sess *sp, const char *reason)
SES_Close(struct sess *sp, enum sess_close reason)
{
int i;
assert(sp->fd >= 0);
VSL(SLT_SessionClose, sp->vsl_id, "%s", reason);
sp->reason = reason;
i = close(sp->fd);
assert(i == 0 || errno != EBADF); /* XXX EINVAL seen */
sp->fd = -1;
......@@ -314,7 +312,7 @@ SES_Close(struct sess *sp, const char *reason)
*/
void
SES_Delete(struct sess *sp, const char *reason, double now)
SES_Delete(struct sess *sp, enum sess_close reason, double now)
{
struct acct *b;
struct sesspool *pp;
......@@ -324,7 +322,7 @@ SES_Delete(struct sess *sp, const char *reason, double now)
CHECK_OBJ_NOTNULL(pp, SESSPOOL_MAGIC);
AN(pp->pool);
if (reason != NULL)
if (reason != SC_NULL)
SES_Close(sp, reason);
if (isnan(now))
now = VTIM_real();
......@@ -338,10 +336,11 @@ SES_Delete(struct sess *sp, const char *reason, double now)
b = &sp->acct_ses;
VSL(SLT_StatSess, sp->vsl_id, "%s %s %.0f %ju %ju %ju %ju %ju %ju %ju",
sp->addr, sp->port,
VSL(SLT_SessClose, sp->vxid,
"%s %.3f %ju %ju %ju %ju %ju %ju",
sess_close_str(sp->reason, 0),
now - sp->t_open,
b->sess, b->req, b->pipe, b->pass,
b->req, b->pipe, b->pass,
b->fetch, b->hdrbytes, b->bodybytes);
MPL_Free(pp->mpl_sess, sp);
......
......@@ -108,6 +108,10 @@
-esym(458, heritage)
-esym(458, name_key)
//////////////
// 436 = Apparent preprocessor directive in invocation of macro '___'
-emacro(436, SLTM)
//////////////
+libh mgt_event.h
......
......@@ -86,7 +86,7 @@ mgt_sltm(const char *tag, const char *sdesc, const char *ldesc)
printf("%s\n", sdesc);
else
printf("%s\n", "(description not yet written)");
}
static void
......
......@@ -74,6 +74,6 @@ WAIT_Enter(struct sess *sp)
* acceptor thread, to reduce syscall density of the latter.
*/
if (VTCP_nonblocking(sp->fd))
SES_Close(sp, "remote closed");
SES_Close(sp, SC_REM_CLOSE);
waiter->pass(waiter_priv, sp);
}
......@@ -133,7 +133,7 @@ vwk_sess_ev(struct vwk *vwk, const struct kevent *kp, double now)
return;
} else if (kp->flags & EV_EOF) {
VTAILQ_REMOVE(&vwk->sesshead, sp, list);
SES_Delete(sp, "EOF", now);
SES_Delete(sp, SC_REM_CLOSE, now);
return;
} else {
VSL(SLT_Debug, sp->vsl_id,
......@@ -204,7 +204,7 @@ vwk_thread(void *priv)
break;
VTAILQ_REMOVE(&vwk->sesshead, sp, list);
// XXX: not yet (void)VTCP_linger(sp->fd, 0);
SES_Delete(sp, "timeout", now);
SES_Delete(sp, SC_RX_TIMEOUT, now);
}
}
}
......
......@@ -162,7 +162,7 @@ vwp_main(void *priv)
VTAILQ_REMOVE(&vwp->sesshead, sp, list);
vwp_unpoll(vwp, fd);
// XXX: not yet (void)VTCP_linger(sp->fd, 0);
SES_Delete(sp, "timeout", now);
SES_Delete(sp, SC_RX_TIMEOUT, now);
}
}
if (v2 && vwp->pollfd[vwp->pipes[0]].revents) {
......
......@@ -115,9 +115,9 @@ h_order(void *priv, enum VSL_tag_e tag, unsigned fd, unsigned len,
ob[fd] = VSB_new_auto();
assert(ob[fd] != NULL);
}
if ((tag == SLT_BackendOpen || tag == SLT_SessionOpen ||
if ((tag == SLT_BackendOpen || tag == SLT_SessOpen ||
(tag == SLT_ReqStart &&
last[fd] != SLT_SessionOpen &&
last[fd] != SLT_SessOpen &&
last[fd] != SLT_VCL_acl) ||
(tag == SLT_BackendXID &&
last[fd] != SLT_BackendOpen)) &&
......@@ -127,7 +127,7 @@ h_order(void *priv, enum VSL_tag_e tag, unsigned fd, unsigned len,
* the end of the previous one. Spit it out anyway before
* starting on the new one.
*/
if (last[fd] != SLT_SessionClose)
if (last[fd] != SLT_SessClose)
VSB_printf(ob[fd], "%5d %-12s %c %s\n",
fd, "Interrupted", type, VSL_tags[tag]);
h_order_finish(fd, vd);
......@@ -165,7 +165,6 @@ h_order(void *priv, enum VSL_tag_e tag, unsigned fd, unsigned len,
case SLT_ReqEnd:
case SLT_BackendClose:
case SLT_BackendReuse:
case SLT_StatSess:
h_order_finish(fd, vd);
break;
default:
......@@ -180,8 +179,8 @@ do_order(struct VSM_data *vd)
int i;
if (!b_flag) {
VSL_Select(vd, SLT_SessionOpen);
VSL_Select(vd, SLT_SessionClose);
VSL_Select(vd, SLT_SessOpen);
VSL_Select(vd, SLT_SessClose);
VSL_Select(vd, SLT_ReqEnd);
}
if (!c_flag) {
......
......@@ -535,11 +535,11 @@ collect_client(struct logline *lp, enum VSL_tag_e tag, unsigned spec,
lp->df_b = trimline(ptr, end);
break;
case SLT_SessionClose:
case SLT_SessClose:
if (!lp->active)
break;
if (strncmp(ptr, "pipe", len) == 0 ||
strncmp(ptr, "error", len) == 0) {
if (strncmp(ptr, "TX_PIPE", len) == 0 ||
strncmp(ptr, "TX_ERROR", len) == 0) {
clean_logline(lp);
break;
}
......
/*-
* Copyright (c) 2012 Varnish Software AS
* All rights reserved.
*
* Author: Poul-Henning Kamp <phk@phk.freebsd.dk>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
/*lint -save -e525 -e539 */
SESS_CLOSE(REM_CLOSE, "Client Closed")
SESS_CLOSE(REQ_CLOSE, "Client requested close")
SESS_CLOSE(REQ_HTTP10, "proto < HTTP.1.1")
SESS_CLOSE(RX_JUNK, "Received junk data")
SESS_CLOSE(RX_OVERFLOW, "Received buffer overflow")
SESS_CLOSE(RX_TIMEOUT, "Receive timeout")
SESS_CLOSE(TX_PIPE, "Piped transaction")
SESS_CLOSE(TX_ERROR, "Error transaction")
SESS_CLOSE(TX_EOF, "EOF transmission")
SESS_CLOSE(OVERLOAD, "Out of some resource")
/*lint -restore */
......@@ -52,7 +52,6 @@ SLTM(Error, "Error messages",
SLTM(CLI, "CLI communication",
"CLI communication between master and child process."
)
SLTM(StatSess, "Session statistics", "")
SLTM(ReqEnd, "Client request end",
"Marks the end of client request.\n\n"
......@@ -64,7 +63,9 @@ SLTM(ReqEnd, "Client request end",
"dTtx\n Time to transmit response\n\n"
)
SLTM(SessionOpen, "Client connection opened",
/*---------------------------------------------------------------------*/
SLTM(SessOpen, "Client connection opened",
"The first record for a client connection, with the\n"
"socket-endpoints of the connection.\n\n"
"caddr\n Client IPv4/6 address\n\n"
......@@ -74,19 +75,24 @@ SLTM(SessionOpen, "Client connection opened",
"lport\n Local TCP port ('-' if !$log_local_addr)\n\n"
)
SLTM(SessionClose, "Client connection closed",
"SessionClose tells you why HTTP client-connections are closed. "
"These can be: "
"'timeout' - No keep-alive was received within sess_timeout. "
"'Connection: close' - The client specifed that keepalive should "
"be disabled by sending a 'Connection: close' header. "
"'no request' - No initial request was received within sess_timeout. "
"'EOF' - ? "
"'remote closed' - ? "
"'error' - Processing reached vcl_error even if the status code "
"indicates success. "
"' blast' - ?"
#define SESS_CLOSE(nm, desc) " " #nm "\n\t" desc "\n\n"
SLTM(SessClose, "Client connection closed",
"SessionClose is the last record for any client connection.\n\n"
"reason\n Why the connection closed.\n\n"
#include <tbl/sess_close.h>
"duration\n How long the session were open.\n\n"
"Nreq\n How many requests on session.\n\n"
"Npipe\n If 'pipe' were used on session.\n\n"
"Npass\n Requests handled with pass.\n\n"
"Nfetch\n Backend fetches by session.\n\n"
"Bhdr\n Header bytes sent on session.\n\n"
"Bbody\n Body bytes sent on session.\n\n"
)
#undef SESS_CLOSE
/*---------------------------------------------------------------------*/
SLTM(BackendOpen, "Backend connection opened", "")
SLTM(BackendXID, "The unique ID of the backend transaction", "")
SLTM(BackendReuse, "Backend connection reused", "")
......
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