Commit 7d257423 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Give VBE_ClosedFd() an argument to tell if the fd has already

been closed.

Pipe does this and would panic otherwise.


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@880 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent ae58797b
...@@ -305,7 +305,7 @@ void VCA_Init(void); ...@@ -305,7 +305,7 @@ void VCA_Init(void);
/* cache_backend.c */ /* cache_backend.c */
void VBE_Init(void); void VBE_Init(void);
struct vbe_conn *VBE_GetFd(struct backend *bp, unsigned xid); 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); void VBE_RecycleFd(struct vbe_conn *vc);
/* cache_ban.c */ /* cache_ban.c */
......
...@@ -209,7 +209,7 @@ VBE_GetFd(struct backend *bp, unsigned xid) ...@@ -209,7 +209,7 @@ VBE_GetFd(struct backend *bp, unsigned xid)
pfd.revents = 0; pfd.revents = 0;
if (!poll(&pfd, 1, 0)) if (!poll(&pfd, 1, 0))
break; break;
VBE_ClosedFd(vc); VBE_ClosedFd(vc, 0);
} }
if (vc == NULL) { if (vc == NULL) {
...@@ -252,14 +252,15 @@ VBE_GetFd(struct backend *bp, unsigned xid) ...@@ -252,14 +252,15 @@ VBE_GetFd(struct backend *bp, unsigned xid)
/* Close a connection ------------------------------------------------*/ /* Close a connection ------------------------------------------------*/
void void
VBE_ClosedFd(struct vbe_conn *vc) VBE_ClosedFd(struct vbe_conn *vc, int already)
{ {
CHECK_OBJ_NOTNULL(vc, VBE_CONN_MAGIC); CHECK_OBJ_NOTNULL(vc, VBE_CONN_MAGIC);
assert(vc->fd >= 0); assert(vc->fd >= 0);
assert(vc->backend != NULL); assert(vc->backend != NULL);
VSL(SLT_BackendClose, vc->fd, "%s", vc->backend->vcl_name); VSL(SLT_BackendClose, vc->fd, "%s", vc->backend->vcl_name);
AZ(close(vc->fd)); if (!already)
AZ(close(vc->fd));
vc->fd = -1; vc->fd = -1;
vc->backend = NULL; vc->backend = NULL;
AZ(pthread_mutex_lock(&vbemtx)); AZ(pthread_mutex_lock(&vbemtx));
......
...@@ -258,7 +258,7 @@ FetchBody(struct sess *sp) ...@@ -258,7 +258,7 @@ FetchBody(struct sess *sp)
cls = 1; cls = 1;
if (cls) if (cls)
VBE_ClosedFd(vc); VBE_ClosedFd(vc, 0);
else else
VBE_RecycleFd(vc); VBE_RecycleFd(vc);
......
...@@ -179,7 +179,7 @@ PassBody(struct sess *sp) ...@@ -179,7 +179,7 @@ PassBody(struct sess *sp)
cls = 1; cls = 1;
if (cls) if (cls)
VBE_ClosedFd(vc); VBE_ClosedFd(vc, 0);
else else
VBE_RecycleFd(vc); VBE_RecycleFd(vc);
} }
......
...@@ -68,7 +68,7 @@ PipeSession(struct sess *sp) ...@@ -68,7 +68,7 @@ PipeSession(struct sess *sp)
if (WRK_Flush(w)) { if (WRK_Flush(w)) {
vca_close_session(sp, "pipe"); vca_close_session(sp, "pipe");
VBE_ClosedFd(vc); VBE_ClosedFd(vc, 0);
return; return;
} }
...@@ -92,5 +92,6 @@ PipeSession(struct sess *sp) ...@@ -92,5 +92,6 @@ PipeSession(struct sess *sp)
rdf(fds, 1); rdf(fds, 1);
} }
vca_close_session(sp, "pipe"); vca_close_session(sp, "pipe");
VBE_ClosedFd(vc); (void)close (vc->fd);
VBE_ClosedFd(vc, 1);
} }
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