From: phk Date: Mon, 21 Aug 2006 20:30:29 +0000 (+0000) Subject: Give VBE_ClosedFd() an argument to tell if the fd has already X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d8913a9ed93679e7422d895ffec4d26a611f983;p=varnish Give VBE_ClosedFd() an argument to tell if the fd has already been closed. Pipe does this and would panic otherwise. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@880 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache.h b/varnish-cache/bin/varnishd/cache.h index 499132ba..50d227cb 100644 --- a/varnish-cache/bin/varnishd/cache.h +++ b/varnish-cache/bin/varnishd/cache.h @@ -305,7 +305,7 @@ void VCA_Init(void); /* cache_backend.c */ void VBE_Init(void); struct vbe_conn *VBE_GetFd(struct backend *bp, unsigned xid); -void VBE_ClosedFd(struct vbe_conn *vc); +void VBE_ClosedFd(struct vbe_conn *vc, int already); void VBE_RecycleFd(struct vbe_conn *vc); /* cache_ban.c */ diff --git a/varnish-cache/bin/varnishd/cache_backend.c b/varnish-cache/bin/varnishd/cache_backend.c index 2edc1e6c..9c8ac6a4 100644 --- a/varnish-cache/bin/varnishd/cache_backend.c +++ b/varnish-cache/bin/varnishd/cache_backend.c @@ -209,7 +209,7 @@ VBE_GetFd(struct backend *bp, unsigned xid) pfd.revents = 0; if (!poll(&pfd, 1, 0)) break; - VBE_ClosedFd(vc); + VBE_ClosedFd(vc, 0); } if (vc == NULL) { @@ -252,14 +252,15 @@ VBE_GetFd(struct backend *bp, unsigned xid) /* Close a connection ------------------------------------------------*/ void -VBE_ClosedFd(struct vbe_conn *vc) +VBE_ClosedFd(struct vbe_conn *vc, int already) { CHECK_OBJ_NOTNULL(vc, VBE_CONN_MAGIC); assert(vc->fd >= 0); assert(vc->backend != NULL); VSL(SLT_BackendClose, vc->fd, "%s", vc->backend->vcl_name); - AZ(close(vc->fd)); + if (!already) + AZ(close(vc->fd)); vc->fd = -1; vc->backend = NULL; AZ(pthread_mutex_lock(&vbemtx)); diff --git a/varnish-cache/bin/varnishd/cache_fetch.c b/varnish-cache/bin/varnishd/cache_fetch.c index 40cad6a9..cf7525b7 100644 --- a/varnish-cache/bin/varnishd/cache_fetch.c +++ b/varnish-cache/bin/varnishd/cache_fetch.c @@ -258,7 +258,7 @@ FetchBody(struct sess *sp) cls = 1; if (cls) - VBE_ClosedFd(vc); + VBE_ClosedFd(vc, 0); else VBE_RecycleFd(vc); diff --git a/varnish-cache/bin/varnishd/cache_pass.c b/varnish-cache/bin/varnishd/cache_pass.c index 27a5aa39..57bc633d 100644 --- a/varnish-cache/bin/varnishd/cache_pass.c +++ b/varnish-cache/bin/varnishd/cache_pass.c @@ -179,7 +179,7 @@ PassBody(struct sess *sp) cls = 1; if (cls) - VBE_ClosedFd(vc); + VBE_ClosedFd(vc, 0); else VBE_RecycleFd(vc); } diff --git a/varnish-cache/bin/varnishd/cache_pipe.c b/varnish-cache/bin/varnishd/cache_pipe.c index 1c3184ba..98b7d9ff 100644 --- a/varnish-cache/bin/varnishd/cache_pipe.c +++ b/varnish-cache/bin/varnishd/cache_pipe.c @@ -68,7 +68,7 @@ PipeSession(struct sess *sp) if (WRK_Flush(w)) { vca_close_session(sp, "pipe"); - VBE_ClosedFd(vc); + VBE_ClosedFd(vc, 0); return; } @@ -92,5 +92,6 @@ PipeSession(struct sess *sp) rdf(fds, 1); } vca_close_session(sp, "pipe"); - VBE_ClosedFd(vc); + (void)close (vc->fd); + VBE_ClosedFd(vc, 1); }