[master] d0eb0f1 Get rid of VCLS_Poll(), we don't need it.

Poul-Henning Kamp phk at FreeBSD.org
Mon Nov 6 09:44:06 UTC 2017


commit d0eb0f1526d627feb1886ba673e3008dbe13dfdf
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Nov 6 09:12:49 2017 +0000

    Get rid of VCLS_Poll(), we don't need it.

diff --git a/bin/varnishd/cache/cache_cli.c b/bin/varnishd/cache/cache_cli.c
index 066398b..343a576 100644
--- a/bin/varnishd/cache/cache_cli.c
+++ b/bin/varnishd/cache/cache_cli.c
@@ -99,8 +99,8 @@ CLI_Run(void)
 	AN(VCLS_AddFd(cls, heritage.cli_in, heritage.cli_out, NULL, NULL));
 
 	do {
-		i = VCLS_Poll(cls, -1);
-	} while (i > 0);
+		i = VCLS_PollFd(cls, heritage.cli_in, -1);
+	} while (i == 0);
 	VSL(SLT_CLI, 0, "EOF on CLI connection, worker stops");
 }
 
diff --git a/include/vcli_serve.h b/include/vcli_serve.h
index 994de9d..ddaaa61 100644
--- a/include/vcli_serve.h
+++ b/include/vcli_serve.h
@@ -97,7 +97,6 @@ struct VCLS *VCLS_New(cls_cbc_f *before, cls_cbc_f *after,
 struct cli *VCLS_AddFd(struct VCLS *cs, int fdi, int fdo, cls_cb_f *closefunc,
     void *priv);
 void VCLS_AddFunc(struct VCLS *cs, unsigned auth, struct cli_proto *clp);
-int VCLS_Poll(struct VCLS *cs, int timeout);
 int VCLS_PollFd(struct VCLS *cs, int fd, int timeout);
 void VCLS_Destroy(struct VCLS **);
 void VCLS_Clone(struct VCLS *cs, struct VCLS *cso);
diff --git a/lib/libvarnish/vcli_serve.c b/lib/libvarnish/vcli_serve.c
index aff32a2..a26c50b 100644
--- a/lib/libvarnish/vcli_serve.c
+++ b/lib/libvarnish/vcli_serve.c
@@ -558,49 +558,6 @@ VCLS_PollFd(struct VCLS *cs, int fd, int timeout)
 	return (k);
 }
 
-int
-VCLS_Poll(struct VCLS *cs, int timeout)
-{
-	struct VCLS_fd *cfd, *cfd2;
-	int i, j, k;
-
-	CHECK_OBJ_NOTNULL(cs, VCLS_MAGIC);
-	if (cs->nfd == 0) {
-		errno = 0;
-		return (-1);
-	}
-	assert(cs->nfd > 0);
-	{
-		struct pollfd pfd[cs->nfd];
-
-		i = 0;
-		VTAILQ_FOREACH(cfd, &cs->fds, list) {
-			pfd[i].fd = cfd->fdi;
-			pfd[i].events = POLLIN;
-			pfd[i].revents = 0;
-			i++;
-		}
-		assert(i == cs->nfd);
-
-		j = poll(pfd, cs->nfd, timeout);
-		if (j <= 0)
-			return (j);
-		i = 0;
-		VTAILQ_FOREACH_SAFE(cfd, &cs->fds, list, cfd2) {
-			assert(pfd[i].fd == cfd->fdi);
-			if (pfd[i].revents & POLLHUP)
-				k = 1;
-			else
-				k = VLU_Fd(cfd->cli->vlu, cfd->fdi);
-			if (k)
-				cls_close_fd(cs, cfd);
-			i++;
-		}
-		assert(i == j);
-	}
-	return (j);
-}
-
 void
 VCLS_Destroy(struct VCLS **csp)
 {


More information about the varnish-commit mailing list