Commit 8624d492 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Move the client IP+port onto the sess structure instead of the

sess workspace.
parent ee439631
......@@ -600,8 +600,8 @@ struct sess {
struct listen_sock *mylsock;
/* formatted ascii client address */
char *addr;
char *port;
char addr[ADDR_BUFSIZE];
char port[PORT_BUFSIZE];
char *client_identity;
/* HTTP request */
......@@ -662,7 +662,7 @@ struct sess {
/* Prototypes etc ----------------------------------------------------*/
/* cache_acceptor.c */
void VCA_Prep(struct sess *sp);
void VCA_Prep(const struct sess *sp);
void VCA_Init(void);
void VCA_Shutdown(void);
int VCA_Accept(struct listen_sock *ls, struct wrk_accept *wa);
......@@ -997,7 +997,6 @@ void WS_ReleaseP(struct ws *ws, char *ptr);
void WS_Assert(const struct ws *ws);
void WS_Reset(struct ws *ws, char *p);
char *WS_Alloc(struct ws *ws, unsigned bytes);
char *WS_Dup(struct ws *ws, const char *);
char *WS_Snapshot(struct ws *ws);
unsigned WS_Free(const struct ws *ws);
......
......@@ -113,27 +113,9 @@ sock_test(int fd)
*/
void
VCA_Prep(struct sess *sp)
VCA_Prep(const struct sess *sp)
{
char addr[VTCP_ADDRBUFSIZE];
char port[VTCP_PORTBUFSIZE];
VTCP_name(&sp->sockaddr, sp->sockaddrlen,
addr, sizeof addr, port, sizeof port);
sp->addr = WS_Dup(sp->ws, addr);
sp->port = WS_Dup(sp->ws, port);
if (cache_param->log_local_addr) {
AZ(getsockname(sp->fd, (void*)&sp->mysockaddr,
&sp->mysockaddrlen));
VTCP_name(&sp->mysockaddr, sp->mysockaddrlen,
addr, sizeof addr, port, sizeof port);
WSP(sp, SLT_SessionOpen, "%s %s %s %s",
sp->addr, sp->port, addr, port);
} else {
WSP(sp, SLT_SessionOpen, "%s %s %s",
sp->addr, sp->port, sp->mylsock->name);
}
sp->acct_ses.first = sp->t_open;
if (need_test)
sock_test(sp->fd);
if (need_linger)
......
......@@ -64,6 +64,8 @@ DOT acceptor -> first [style=bold,color=green]
#include "cache.h"
#include "common/heritage.h"
#include "hash/hash_slinger.h"
#include "vcl.h"
#include "vcli_priv.h"
......@@ -1005,6 +1007,8 @@ static int
cnt_first(struct sess *sp)
{
struct worker *wrk;
char laddr[ADDR_BUFSIZE];
char lport[PORT_BUFSIZE];
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
wrk = sp->wrk;
......@@ -1020,6 +1024,21 @@ cnt_first(struct sess *sp)
assert(sp->xid == 0);
assert(sp->restarts == 0);
AZ(sp->esi_level);
VTCP_name(&sp->sockaddr, sp->sockaddrlen,
sp->addr, sizeof sp->addr, sp->port, sizeof sp->port);
if (cache_param->log_local_addr) {
AZ(getsockname(sp->fd, (void*)&sp->mysockaddr,
&sp->mysockaddrlen));
VTCP_name(&sp->mysockaddr, sp->mysockaddrlen,
laddr, sizeof laddr, lport, sizeof lport);
WSP(sp, SLT_SessionOpen, "%s %s %s %s",
sp->addr, sp->port, laddr, lport);
} else {
WSP(sp, SLT_SessionOpen, "%s %s %s",
sp->addr, sp->port, sp->mylsock->name);
}
sp->acct_ses.first = sp->t_open;
VCA_Prep(sp);
/* Record the session watermark */
......
......@@ -321,7 +321,6 @@ SES_Delete(struct sess *sp, const char *reason)
{
struct acct *b;
struct sessmem *sm;
static char noaddr[] = "-";
struct worker *wrk;
struct sesspool *pp;
......@@ -340,10 +339,10 @@ SES_Delete(struct sess *sp, const char *reason)
assert(sp->fd < 0);
AZ(sp->vcl);
if (sp->addr == NULL)
sp->addr = noaddr;
if (sp->port == NULL)
sp->port = noaddr;
if (*sp->addr == '\0')
strcpy(sp->addr, "-");
if (*sp->port == '\0')
strcpy(sp->addr, "-");
b = &sp->acct_ses;
assert(!isnan(b->first));
......
......@@ -116,22 +116,6 @@ WS_Alloc(struct ws *ws, unsigned bytes)
return (r);
}
char *
WS_Dup(struct ws *ws, const char *s)
{
unsigned l;
char *p;
WS_Assert(ws);
l = strlen(s) + 1;
p = WS_Alloc(ws, l);
if (p != NULL)
memcpy(p, s, l);
DSL(0x02, SLT_Debug, 0, "WS_Dup(%p, \"%s\") = %p", ws, s, p);
WS_Assert(ws);
return (p);
}
unsigned
WS_Free(const struct ws *ws)
{
......
......@@ -60,6 +60,15 @@ struct cli;
*/
#define __state_variable__(xxx) /*lint -esym(838,xxx) */
/**********************************************************************
* NI_MAXHOST and less so NI_MAXSERV, are ridiculously large for numeric
* representations of TCP/IP socket addresses, so we use our own.
*/
#define ADDR_BUFSIZE 64
#define PORT_BUFSIZE 8
/**********************************************************************/
/* Name of transient storage */
......
......@@ -51,8 +51,8 @@ varnish v1 -arg "-p sess_workspace=1024" -vcl+backend {
"0123456789abcdef" + "0123456789abcdef" +
"0123456789abcdef" + "0123456789abcdef" +
"0123456789abcdef" + "0123456789abcdef" +
"0123456789abcdef" +
"0123456";
"0123456789abcdef" + "0123456789abcdef" +
"0123456789abcde";
set req.http.baz = "BAZ";
return (pass);
}
......
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