[master] 4e5107d Attempt to allocate the htc before the backend connection, its cheaper to eliminate the exceedingly unlikely resource leak Coverity spotted that way.
Poul-Henning Kamp
phk at FreeBSD.org
Thu May 14 10:04:15 CEST 2015
commit 4e5107db50d41ed74fb23e316f5fb6d406b94ed4
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Thu May 14 08:02:04 2015 +0000
Attempt to allocate the htc before the backend connection,
its cheaper to eliminate the exceedingly unlikely resource leak
Coverity spotted that way.
diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c
index 32189df..9aac126 100644
--- a/bin/varnishd/cache/cache_backend.c
+++ b/bin/varnishd/cache/cache_backend.c
@@ -105,11 +105,18 @@ vbe_dir_getfd(const struct director *d, struct busyobj *bo)
return (-1);
}
+ AZ(bo->htc);
+ bo->htc = WS_Alloc(bo->ws, sizeof *bo->htc);
+ if (bo->htc == NULL)
+ /* XXX: counter ? */
+ return (-1);
+
FIND_TMO(connect_timeout, tmod, bo, vrt);
vc = VBT_Get(bp->tcp_pool, tmod);
if (vc == NULL) {
// XXX: Per backend stats ?
VSC_C_main->backend_fail++;
+ bo->htc = NULL;
return (-1);
}
@@ -129,11 +136,6 @@ vbe_dir_getfd(const struct director *d, struct busyobj *bo)
vc->fd, bp->display_name, abuf2, pbuf2, abuf1, pbuf1);
vc->backend->vsc->req++;
- AZ(bo->htc);
- bo->htc = WS_Alloc(bo->ws, sizeof *bo->htc);
- if (bo->htc == NULL)
- /* XXX: counter ? */
- return (-1);
INIT_OBJ(bo->htc, HTTP_CONN_MAGIC);
bo->htc->vbc = vc;
bo->htc->fd = vc->fd;
More information about the varnish-commit
mailing list