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

Add a vca_recycle_session() function which sticks a session back into

the acceptors event engine.

Do Id keyword



git-svn-id: http://www.varnish-cache.org/svn/trunk@127 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent a5ce87c3
......@@ -18,6 +18,7 @@ struct worker;
/* cache_acceptor.c */
void *vca_main(void *arg);
void vca_retire_session(struct sess *sp);
void vca_recycle_session(struct sess *sp);
/* cache_backend.c */
void VBE_Init(void);
......
/*
* $Id$
*
* XXX: We need to pass sessions back into the event engine when they are
* reused. Not sure what the most efficient way is for that. For now
* write the session pointer to a pipe which the event engine monitors.
*/
#include <stdio.h>
......@@ -25,6 +29,8 @@
#include "cache.h"
static struct event_base *evb;
static struct event pipe_e;
static int pipes[2];
static struct event accept_e[2 * HERITAGE_NSOCKS];
......@@ -33,6 +39,17 @@ struct sessmem {
struct event e;
};
static void
pipe_f(int fd, short event, void *arg)
{
struct sess *sp;
int i;
i = read(fd, &sp, sizeof sp);
assert(i == sizeof sp);
HttpdGetHead(sp, evb, DealWithSession);
}
static void
accept_f(int fd, short event, void *arg)
{
......@@ -74,8 +91,13 @@ vca_main(void *arg)
unsigned u;
struct event *ep;
AZ(pipe(pipes));
evb = event_init();
event_set(&pipe_e, pipes[0], EV_READ | EV_PERSIST, pipe_f, NULL);
event_base_set(evb, &pipe_e);
event_add(&pipe_e, NULL);
ep = accept_e;
for (u = 0; u < HERITAGE_NSOCKS; u++) {
if (heritage.sock_local[u] >= 0) {
......@@ -101,10 +123,18 @@ vca_main(void *arg)
return ("FOOBAR");
}
void
vca_recycle_session(struct sess *sp)
{
VSL(SLT_SessionReuse, sp->fd, "%s", sp->addr);
write(pipes[1], &sp, sizeof sp);
}
void
vca_retire_session(struct sess *sp)
{
VSL(SLT_SessionClose, sp->fd, "%s", sp->addr);
if (sp->fd >= 0)
close(sp->fd);
free(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