[6.3] e1d857150 Fix vrt_priv_dyncmp() to provide total ordering

Nils Goroll nils.goroll at uplex.de
Sat Jan 23 18:27:07 UTC 2021


commit e1d85715065a2d1684d06062a6c059d857c9cb10
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Sat Jan 23 18:51:13 2021 +0100

    Fix vrt_priv_dyncmp() to provide total ordering
    
    Fixes #3505, see ticket for detailed explanation.

diff --git a/bin/varnishd/cache/cache_vrt_priv.c b/bin/varnishd/cache/cache_vrt_priv.c
index 76152cbf3..ad91c01b0 100644
--- a/bin/varnishd/cache/cache_vrt_priv.c
+++ b/bin/varnishd/cache/cache_vrt_priv.c
@@ -96,9 +96,13 @@ VRTPRIV_init(struct vrt_privs *privs)
 static inline int
 vrt_priv_dyncmp(const struct vrt_priv *vp1, const struct vrt_priv *vp2)
 {
-	if (vp1->vmod_id < vp2->vmod_id || vp1->id < vp2->id)
+	if (vp1->vmod_id < vp2->vmod_id)
 		return (-1);
-	if (vp1->vmod_id > vp2->vmod_id || vp1->id > vp2->id)
+	if (vp1->vmod_id > vp2->vmod_id)
+		return (1);
+	if (vp1->id < vp2->id)
+		return (-1);
+	if (vp1->id > vp2->id)
 		return (1);
 	return (0);
 }


More information about the varnish-commit mailing list