[master] 9123362 put the session's struct waited on the ws while waiting

Nils Goroll nils.goroll at uplex.de
Fri May 29 13:38:52 CEST 2015


commit 9123362ff7ea51a1e1d7e430c33b2efdb5c938f5
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Fri May 29 13:38:48 2015 +0200

    put the session's struct waited on the ws while waiting

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 399fdcb..fa7ec7a 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -636,7 +636,7 @@ struct sess {
 
 	struct pool		*pool;
 
-	struct waited		waited;
+	struct waited		*waited;	// on ws while waiting
 
 	/* Session related fields ------------------------------------*/
 
diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c
index 2d55cba..e8824c8 100644
--- a/bin/varnishd/cache/cache_session.c
+++ b/bin/varnishd/cache/cache_session.c
@@ -431,8 +431,12 @@ ses_handle(struct waited *wp, enum wait_event ev, double now)
 
 	CHECK_OBJ_NOTNULL(wp, WAITED_MAGIC);
 	CAST_OBJ_NOTNULL(sp, wp->ptr, SESS_MAGIC);
+	assert(sp->waited == wp);
+	wp->magic = 0;
+	wp = NULL;
+	sp->waited = NULL;
 
-	AZ(sp->ws->r);
+	WS_Release(sp->ws, 0);
 
 	switch (ev) {
 	case WAITER_TIMEOUT:
@@ -478,12 +482,19 @@ SES_Wait(struct sess *sp)
 		SES_Delete(sp, SC_REM_CLOSE, NAN);
 		return;
 	}
-	sp->waited.magic = WAITED_MAGIC;
-	sp->waited.fd = sp->fd;
-	sp->waited.ptr = sp;
-	sp->waited.idle = sp->t_idle;
-	sp->waited.waitfor = &pp->wf;
-	if (Wait_Enter(pp->waiter, &sp->waited))
+
+	AZ(sp->waited);
+	if (WS_Reserve(sp->ws, sizeof(struct waited))
+	    < sizeof(struct waited)) {
+		SES_Delete(sp, SC_OVERLOAD, NAN);
+	}
+	sp->waited = (void*)sp->ws->f;
+	INIT_OBJ(sp->waited, WAITED_MAGIC);
+	sp->waited->fd = sp->fd;
+	sp->waited->ptr = sp;
+	sp->waited->idle = sp->t_idle;
+	sp->waited->waitfor = &pp->wf;
+	if (Wait_Enter(pp->waiter, sp->waited))
 		SES_Delete(sp, SC_PIPE_OVERFLOW, NAN);
 }
 



More information about the varnish-commit mailing list