r127 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Thu Apr 6 11:09:09 CEST 2006


Author: phk
Date: 2006-04-06 11:09:09 +0200 (Thu, 06 Apr 2006)
New Revision: 127

Modified:
   trunk/varnish-cache/bin/varnishd/cache.h
   trunk/varnish-cache/bin/varnishd/cache_acceptor.c
Log:
Add a vca_recycle_session() function which sticks a session back into
the acceptors event engine.

Do Id keyword



Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h	2006-04-06 09:08:13 UTC (rev 126)
+++ trunk/varnish-cache/bin/varnishd/cache.h	2006-04-06 09:09:09 UTC (rev 127)
@@ -18,6 +18,7 @@
 /* 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);

Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_acceptor.c	2006-04-06 09:08:13 UTC (rev 126)
+++ trunk/varnish-cache/bin/varnishd/cache_acceptor.c	2006-04-06 09:09:09 UTC (rev 127)
@@ -1,5 +1,9 @@
 /*
  * $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];
 
@@ -34,6 +40,17 @@
 };
 
 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)
 {
 	socklen_t l;
@@ -74,8 +91,13 @@
 	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) {
@@ -102,9 +124,17 @@
 }
 
 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);


Property changes on: trunk/varnish-cache/bin/varnishd/cache_acceptor.c
___________________________________________________________________
Name: svn:keywords
   + Id




More information about the varnish-commit mailing list