]> err.no Git - varnish/commitdiff
Give VBE_ClosedFd() an argument to tell if the fd has already
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 21 Aug 2006 20:30:29 +0000 (20:30 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 21 Aug 2006 20:30:29 +0000 (20:30 +0000)
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

varnish-cache/bin/varnishd/cache.h
varnish-cache/bin/varnishd/cache_backend.c
varnish-cache/bin/varnishd/cache_fetch.c
varnish-cache/bin/varnishd/cache_pass.c
varnish-cache/bin/varnishd/cache_pipe.c

index 499132ba84a8f56d88b1de3a7fbf9a8466004dda..50d227cb0e813afd8f6e643bad3495e1233085bd 100644 (file)
@@ -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 */
index 2edc1e6c31d1f9154db1adac733d1f8294d06658..9c8ac6a4a904493923d293fac9f7b5e73a35057d 100644 (file)
@@ -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));
index 40cad6a97fca53c4a3f5bf346116264a88cf91d7..cf7525b7dd932611842452aeae975fe5e8d398d3 100644 (file)
@@ -258,7 +258,7 @@ FetchBody(struct sess *sp)
                cls = 1;
 
        if (cls)
-               VBE_ClosedFd(vc);
+               VBE_ClosedFd(vc, 0);
        else
                VBE_RecycleFd(vc);
 
index 27a5aa3971520118d269024dce30d0b8482037d1..57bc633db3685782e72ed323416b1c42851d8cfb 100644 (file)
@@ -179,7 +179,7 @@ PassBody(struct sess *sp)
                cls = 1;
 
        if (cls)
-               VBE_ClosedFd(vc);
+               VBE_ClosedFd(vc, 0);
        else
                VBE_RecycleFd(vc);
 }
index 1c3184bae9dfc695968faf064660c9e7466c7967..98b7d9ffc6008fa4d2ab108396a91e6a884c6b65 100644 (file)
@@ -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);
 }