summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/pseudo
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2017-04-25 15:25:54 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-06-22 09:16:00 +0100
commit8cbdc270c9663bcdc314fec19de51e85a6461a94 (patch)
tree5476361a41e790a8841e4d218a228c840098e97b /meta/recipes-devtools/pseudo
parent9ea5a31776440abd6468f003c5e1905f079446d3 (diff)
downloadpoky-8cbdc270c9663bcdc314fec19de51e85a6461a94.tar.gz
pseudo: Handle too many files deadlock
If we have large amounts of parallelism, pseudo can end up with too many open connections and will no longer accept further connections, hanging. This patch works around that by closing some clients, allowing turnover of connections and unblocking the system. The downside is a small but theoretical window of data loss. This is likely better than locking up entirely though. Discussions with Peter are onging about how we could better fix this. (From OE-Core rev: f3589f154dad1c92e599737623d392508810ae7e) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/pseudo')
-rw-r--r--meta/recipes-devtools/pseudo/files/toomanyfiles.patch62
-rw-r--r--meta/recipes-devtools/pseudo/pseudo_1.8.2.bb1
2 files changed, 63 insertions, 0 deletions
diff --git a/meta/recipes-devtools/pseudo/files/toomanyfiles.patch b/meta/recipes-devtools/pseudo/files/toomanyfiles.patch
new file mode 100644
index 0000000000..7319ab29bf
--- /dev/null
+++ b/meta/recipes-devtools/pseudo/files/toomanyfiles.patch
@@ -0,0 +1,62 @@
1Currently if we max out the maximum number of files, pseudo can deadlock, unable to
2accept new connections yet unable to move forward and unblock the other processes
3waiting either.
4
5Rather than hang, when this happens, close out inactive connections, allowing us
6to accept the new ones. The disconnected clients will simply reconnect. There is
7a small risk of data loss here sadly but its better than hanging.
8
9RP
102017/4/25
11
12Upstream-Status: Pending [Peter is aware of the issue]
13
14Index: pseudo-1.8.2/pseudo_server.c
15===================================================================
16--- pseudo-1.8.2.orig/pseudo_server.c
17+++ pseudo-1.8.2/pseudo_server.c
18@@ -581,6 +581,7 @@ pseudo_server_loop(void) {
19 int rc;
20 int fd;
21 int loop_timeout = pseudo_server_timeout;
22+ int hitmaxfiles;
23
24 clients = malloc(16 * sizeof(*clients));
25
26@@ -597,6 +598,7 @@ pseudo_server_loop(void) {
27 active_clients = 1;
28 max_clients = 16;
29 highest_client = 0;
30+ hitmaxfiles = 0;
31
32 pseudo_debug(PDBGF_SERVER, "server loop started.\n");
33 if (listen_fd < 0) {
34@@ -663,10 +665,18 @@ pseudo_server_loop(void) {
35 message_time.tv_usec -= 1000000;
36 ++message_time.tv_sec;
37 }
38+ } else if (hitmaxfiles) {
39+ /* In theory there is a potential race here where if we close a client,
40+ it may have sent us a fastop message which we don't act upon.
41+ If we don't close a filehandle we'll loop indefinitely thought.
42+ Only close one per loop iteration in the interests of caution */
43+ close_client(i);
44+ hitmaxfiles = 0;
45 }
46 if (die_forcefully)
47 break;
48 }
49+ hitmaxfiles = 0;
50 if (!die_forcefully &&
51 (FD_ISSET(clients[0].fd, &events) ||
52 FD_ISSET(clients[0].fd, &reads))) {
53@@ -688,6 +698,9 @@ pseudo_server_loop(void) {
54 */
55 pseudo_server_timeout = DEFAULT_PSEUDO_SERVER_TIMEOUT;
56 die_peacefully = 0;
57+ } else if (errno == EMFILE) {
58+ hitmaxfiles = 1;
59+ pseudo_debug(PDBGF_SERVER, "Hit max open files, dropping a client.\n");
60 }
61 }
62 pseudo_debug(PDBGF_SERVER, "server loop complete [%d clients left]\n", active_clients);
diff --git a/meta/recipes-devtools/pseudo/pseudo_1.8.2.bb b/meta/recipes-devtools/pseudo/pseudo_1.8.2.bb
index b427b9ac3c..9bcd031892 100644
--- a/meta/recipes-devtools/pseudo/pseudo_1.8.2.bb
+++ b/meta/recipes-devtools/pseudo/pseudo_1.8.2.bb
@@ -7,6 +7,7 @@ SRC_URI = "http://downloads.yoctoproject.org/releases/pseudo/${BPN}-${PV}.tar.bz
7 file://moreretries.patch \ 7 file://moreretries.patch \
8 file://efe0be279901006f939cd357ccee47b651c786da.patch \ 8 file://efe0be279901006f939cd357ccee47b651c786da.patch \
9 file://b6b68db896f9963558334aff7fca61adde4ec10f.patch \ 9 file://b6b68db896f9963558334aff7fca61adde4ec10f.patch \
10 file://toomanyfiles.patch \
10 " 11 "
11 12
12SRC_URI[md5sum] = "7d41e72188fbea1f696c399c1a435675" 13SRC_URI[md5sum] = "7d41e72188fbea1f696c399c1a435675"