[master] 3e2fd5ac1 varnishtest: refactor client_proxy() in preparation of next commit(s)

Nils Goroll nils.goroll at uplex.de
Fri Feb 21 12:19:11 UTC 2025


commit 3e2fd5ac1a4a30d8717fbadc920f8d35131c1d82
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Fri Feb 21 11:30:23 2025 +0100

    varnishtest: refactor client_proxy() in preparation of next commit(s)

diff --git a/bin/varnishtest/vtc_client.c b/bin/varnishtest/vtc_client.c
index 6142f78eb..1e52f6cdb 100644
--- a/bin/varnishtest/vtc_client.c
+++ b/bin/varnishtest/vtc_client.c
@@ -74,26 +74,31 @@ static VTAILQ_HEAD(, client)	clients = VTAILQ_HEAD_INITIALIZER(clients);
  */
 
 static void
-client_proxy(struct vtclog *vl, int fd, int version, const char *spec)
+client_proxy(struct vtclog *vl, int fd, int version, const char *speca)
 {
 	const struct suckaddr *sac, *sas;
-	char *p, *p2;
+	char *spec, *save, *p;
 
-	p = strdup(spec);
-	AN(p);
-	p2 = strchr(p, ' ');
-	AN(p2);
-	*p2++ = '\0';
+	spec = strdup(speca);
+	AN(spec);
+	save = NULL;
 
+	p = strtok_r(spec, " ", &save);
+	AN(p);
 	sac = VSS_ResolveOne(NULL, p, NULL, 0, SOCK_STREAM, AI_PASSIVE);
 	if (sac == NULL)
 		vtc_fatal(vl, "Could not resolve client address");
-	sas = VSS_ResolveOne(NULL, p2, NULL, 0, SOCK_STREAM, AI_PASSIVE);
+
+	p = strtok_r(NULL, " ", &save);
+	AN(p);
+	sas = VSS_ResolveOne(NULL, p, NULL, 0, SOCK_STREAM, AI_PASSIVE);
 	if (sas == NULL)
-		vtc_fatal(vl, "Could not resolve server address");
+		vtc_fatal(vl, "Could not resolve client address");
+
+	free(spec);
+
 	if (vtc_send_proxy(fd, version, sac, sas))
 		vtc_fatal(vl, "Write failed: %s", strerror(errno));
-	free(p);
 	VSA_free(&sac);
 	VSA_free(&sas);
 }


More information about the varnish-commit mailing list