Skip to content

Commit

Permalink
Copy timeouts from a via backend if undefined for the destination
Browse files Browse the repository at this point in the history
note: use of isnan() is for forward compatibility, at the moment, we use
-1 to denone NAN for backends.
  • Loading branch information
nigoroll committed May 27, 2024
1 parent 97537cb commit 6d1ea03
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
12 changes: 12 additions & 0 deletions bin/varnishd/cache/cache_backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,18 @@ VRT_new_backend_clustered(VRT_CTX, struct vsmw_cluster *vc,
#undef DA
#undef DN

#define CPTMO(a, b, x) do { \
if ((a)->x < 0.0 || isnan((a)->x)) \
(a)->x = (b)->x; \
} while(0)

if (viabe != NULL) {
CPTMO(be, viabe, connect_timeout);
CPTMO(be, viabe, first_byte_timeout);
CPTMO(be, viabe, between_bytes_timeout);
}
#undef CPTMO

if (viabe || be->hosthdr == NULL) {
if (vrt->endpoint->uds_path != NULL)
sa = bogo_ip;
Expand Down
5 changes: 5 additions & 0 deletions doc/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ Varnish Cache NEXT (2024-09-15)
.. PLEASE keep this roughly in commit order as shown by git-log / tig
(new to old)
* for backends using the ``.via`` attribute to connect through a
*proxy*, the ``connect_timeout``, ``first_byte_timeout`` and
``between_bytes_timeout`` attributes are now inherited from *proxy*
unless explicitly given.

* ``varnishd`` now creates a ``worker_tmpdir`` which can be used by
VMODs for temporary files. The `VMOD deleveloper documentation`_ has
details.
Expand Down
4 changes: 4 additions & 0 deletions doc/sphinx/reference/vcl-backend.rst
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ supported.
The ``.via`` attribute is unrelated to ``.proxy_header``. If both are
used, a second header is sent as per ``.proxy_header`` specification.

Unless specified for *destination*, the ``connect_timeout``,
``first_byte_timeout`` and ``between_bytes_timeout`` attributes are
copied from *proxy* to *destination*.

As of this release, the *proxy* backend used with ``.via`` can not be
a director, it can not itself use ``.via`` (error: *Can not stack .via
backends*) and the protocol is fixed to `PROXY2`_.
Expand Down

0 comments on commit 6d1ea03

Please sign in to comment.