Mailing List Archive

r880 - trunk/varnish-cache/bin/varnishd
Author: phk
Date: 2006-08-21 22:30:29 +0200 (Mon, 21 Aug 2006)
New Revision: 880

Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_backend.c
trunk/varnish-cache/bin/varnishd/cache_fetch.c
trunk/varnish-cache/bin/varnishd/cache_pass.c
trunk/varnish-cache/bin/varnishd/cache_pipe.c
Log:
Give VBE_ClosedFd() an argument to tell if the fd has already
been closed.

Pipe does this and would panic otherwise.


Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2006-08-21 20:25:28 UTC (rev 879)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2006-08-21 20:30:29 UTC (rev 880)
@@ -305,7 +305,7 @@
/* 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 */

Modified: trunk/varnish-cache/bin/varnishd/cache_backend.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend.c 2006-08-21 20:25:28 UTC (rev 879)
+++ trunk/varnish-cache/bin/varnishd/cache_backend.c 2006-08-21 20:30:29 UTC (rev 880)
@@ -209,7 +209,7 @@
pfd.revents = 0;
if (!poll(&pfd, 1, 0))
break;
- VBE_ClosedFd(vc);
+ VBE_ClosedFd(vc, 0);
}

if (vc == NULL) {
@@ -252,14 +252,15 @@
/* 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));

Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2006-08-21 20:25:28 UTC (rev 879)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2006-08-21 20:30:29 UTC (rev 880)
@@ -258,7 +258,7 @@
cls = 1;

if (cls)
- VBE_ClosedFd(vc);
+ VBE_ClosedFd(vc, 0);
else
VBE_RecycleFd(vc);


Modified: trunk/varnish-cache/bin/varnishd/cache_pass.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pass.c 2006-08-21 20:25:28 UTC (rev 879)
+++ trunk/varnish-cache/bin/varnishd/cache_pass.c 2006-08-21 20:30:29 UTC (rev 880)
@@ -179,7 +179,7 @@
cls = 1;

if (cls)
- VBE_ClosedFd(vc);
+ VBE_ClosedFd(vc, 0);
else
VBE_RecycleFd(vc);
}

Modified: trunk/varnish-cache/bin/varnishd/cache_pipe.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pipe.c 2006-08-21 20:25:28 UTC (rev 879)
+++ trunk/varnish-cache/bin/varnishd/cache_pipe.c 2006-08-21 20:30:29 UTC (rev 880)
@@ -68,7 +68,7 @@

if (WRK_Flush(w)) {
vca_close_session(sp, "pipe");
- VBE_ClosedFd(vc);
+ VBE_ClosedFd(vc, 0);
return;
}

@@ -92,5 +92,6 @@
rdf(fds, 1);
}
vca_close_session(sp, "pipe");
- VBE_ClosedFd(vc);
+ (void)close (vc->fd);
+ VBE_ClosedFd(vc, 1);
}