Commit 5f67fbdb authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Store the socket address in the session


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@557 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent bc43663f
......@@ -207,6 +207,9 @@ struct sess {
struct worker *wrk;
unsigned sockaddrlen;
struct sockaddr *sockaddr;
/* formatted ascii client address */
char addr[TCP_ADDRBUFSIZE];
char port[TCP_PORTBUFSIZE];
......
......@@ -15,6 +15,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/uio.h>
#include <sys/socket.h>
#include "libvarnish.h"
#include "heritage.h"
......@@ -27,11 +28,12 @@
/*--------------------------------------------------------------------*/
struct sessmem {
unsigned magic;
#define SESSMEM_MAGIC 0x555859c5
unsigned magic;
#define SESSMEM_MAGIC 0x555859c5
struct sess sess;
struct http http;
struct sess sess;
struct http http;
struct sockaddr sockaddr[2]; /* INET6 hack */
};
/*--------------------------------------------------------------------*/
......@@ -166,8 +168,6 @@ SES_New(struct sockaddr *addr, unsigned len)
{
struct sessmem *sm;
(void)addr; /* XXX */
(void)len; /* XXX */
sm = calloc(
sizeof *sm + heritage.mem_workspace,
1);
......@@ -178,6 +178,11 @@ SES_New(struct sockaddr *addr, unsigned len)
sm->sess.magic = SESS_MAGIC;
sm->sess.mem = sm;
sm->sess.http = &sm->http;
sm->sess.sockaddr = sm->sockaddr;
assert(len < sizeof(sm->sockaddr));
memcpy(sm->sess.sockaddr, addr, len);
sm->sess.sockaddrlen = len;
http_Setup(&sm->http, (void *)(sm + 1), heritage.mem_workspace);
return (&sm->sess);
}
......
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