threads looping in PipeSession()
Poul-Henning Kamp
phk at phk.freebsd.dk
Wed Sep 26 21:48:12 CEST 2007
In message <48271.213.180.137.172.1190721848.squirrel at micro.fsi.pl>, "Michal Belczyk" writes:
>Hello,
>
>while testing varnish I noticed several threads consuming 100% of the cpu
>time:
>
>shutdown(5221, 1 /* send */) = 0
>poll([{fd=5221, events=POLLIN|POLLERR}, {fd=5172, events=0,
>revents=POLLHUP}], 2, 60000) = 1
Can you try this patch:
Index: cache_pipe.c
===================================================================
--- cache_pipe.c (revision 2043)
+++ cache_pipe.c (working copy)
@@ -45,11 +45,14 @@
static void
rdf(struct pollfd *fds, int idx)
{
- int i, j;
+ int i, j, rev;
char buf[BUFSIZ], *p;
- i = read(fds[idx].fd, buf, sizeof buf);
- if (i <= 0 || fds[1-idx].events == 0) {
+ rev = fds[idx].revents & POLLHUP;
+ if (!rev)
+ i = read(fds[idx].fd, buf, sizeof buf);
+
+ if (rev || i <= 0 || fds[1-idx].events == 0) {
AZ(shutdown(fds[idx].fd, SHUT_RD));
AZ(shutdown(fds[1-idx].fd, SHUT_WR));
fds[idx].events = 0;
--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
More information about the varnish-bugs
mailing list