summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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"