[package] mountd: correctly handle poll() timeout case, solves possible 100% CPU...
[openwrt/svn-archive/archive.git] / package / mountd / patches / 020-handle_timeout.patch
1 --- a/lib/autofs.c
2 +++ b/lib/autofs.c
3 @@ -140,6 +140,7 @@ static int fullread(void *ptr, size_t le
4
5 static int autofs_in(union autofs_v5_packet_union *pkt)
6 {
7 + int res;
8 struct pollfd fds[1];
9
10 fds[0].fd = fdout;
11 @@ -147,15 +148,19 @@ static int autofs_in(union autofs_v5_pac
12
13 while(1)
14 {
15 - if(poll(fds, 2, 1000) == -1)
16 + res = poll(fds, 1, -1);
17 +
18 + if (res == -1)
19 {
20 if (errno == EINTR)
21 continue;
22 log_printf("failed while trying to read packet from kernel\n");
23 return -1;
24 }
25 - if(fds[0].revents & POLLIN)
26 + else if ((res > 0) && (fds[0].revents & POLLIN))
27 + {
28 return fullread(pkt, sizeof(*pkt));
29 + }
30 }
31 }
32