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);
/* 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 */
......
......@@ -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,13 +252,14 @@ 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);
if (!already)
AZ(close(vc->fd));
vc->fd = -1;
vc->backend = NULL;
......
......@@ -258,7 +258,7 @@ FetchBody(struct sess *sp)
cls = 1;
if (cls)
VBE_ClosedFd(vc);
VBE_ClosedFd(vc, 0);
else
VBE_RecycleFd(vc);
......
......@@ -179,7 +179,7 @@ PassBody(struct sess *sp)
cls = 1;
if (cls)
VBE_ClosedFd(vc);
VBE_ClosedFd(vc, 0);
else
VBE_RecycleFd(vc);
}
......
......@@ -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);
}
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