summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kanavin <alexander.kanavin@linux.intel.com>2018-03-01 15:53:46 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-03-04 11:35:41 +0000
commitd50b9c511e17c6f582ef39b61eaaa8d4555eabba (patch)
tree794a20e7d91cc313086994a2c73bb81dddf363dc
parentf0a5815732f3e62da51fbb89d35c2fbee84aac0f (diff)
downloadpoky-d50b9c511e17c6f582ef39b61eaaa8d4555eabba.tar.gz
pseudo: update to latest master
Dropped patches: 0001-Use-epoll-API-on-Linux.patch replaced by http://git.yoctoproject.org/cgit/cgit.cgi/pseudo/commit/?id=0a3e435085046f535074f498a3de75a7704fb14c (also add --enable-epoll to configure options) b6b68db896f9963558334aff7fca61adde4ec10f.patch merged upstream efe0be279901006f939cd357ccee47b651c786da.patch merged upstream fastopreply.patch replaced by http://git.yoctoproject.org/cgit/cgit.cgi/pseudo/commit/?id=449c234d3030328fb997b309511bb54598848a05 toomanyfiles.patch rebased (From OE-Core rev: 7c3df6782bbd5b623dcb6ee8a9bc914926640cdd) Signed-off-by: Alexander Kanavin <alexander.kanavin@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/recipes-devtools/pseudo/files/0001-Use-epoll-API-on-Linux.patch292
-rw-r--r--meta/recipes-devtools/pseudo/files/b6b68db896f9963558334aff7fca61adde4ec10f.patch48
-rw-r--r--meta/recipes-devtools/pseudo/files/efe0be279901006f939cd357ccee47b651c786da.patch99
-rw-r--r--meta/recipes-devtools/pseudo/files/fastopreply.patch76
-rw-r--r--meta/recipes-devtools/pseudo/files/toomanyfiles.patch44
-rw-r--r--meta/recipes-devtools/pseudo/pseudo.inc2
-rw-r--r--meta/recipes-devtools/pseudo/pseudo_1.8.2.bb16
-rw-r--r--meta/recipes-devtools/pseudo/pseudo_git.bb11
8 files changed, 34 insertions, 554 deletions
diff --git a/meta/recipes-devtools/pseudo/files/0001-Use-epoll-API-on-Linux.patch b/meta/recipes-devtools/pseudo/files/0001-Use-epoll-API-on-Linux.patch
deleted file mode 100644
index 42557b17a7..0000000000
--- a/meta/recipes-devtools/pseudo/files/0001-Use-epoll-API-on-Linux.patch
+++ /dev/null
@@ -1,292 +0,0 @@
1From 9e407e0be01695e7b927f5820ade87ee9602c248 Mon Sep 17 00:00:00 2001
2From: Alexander Kanavin <alex.kanavin@gmail.com>
3Date: Fri, 15 Sep 2017 17:00:14 +0300
4Subject: [PATCH] Use epoll API on Linux
5
6Also a couple of other modifications due to epoll having
7a different approach to how the working set of fds is defined
8and used:
91) open_client() returns an index into the array of clients
102) close_client() has a protection against being called twice
11with the same client (which would mess up the active_clients
12counter)
13
14Upstream-Status: Submitted [Seebs CC'd by email]
15Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
16
17---
18 enums/exit_status.in | 3 +
19 pseudo_server.c | 189 ++++++++++++++++++++++++++++++++++++++++++++++++++-
20 2 files changed, 190 insertions(+), 2 deletions(-)
21
22diff --git a/enums/exit_status.in b/enums/exit_status.in
23index 6be44d3..88f94cd 100644
24--- a/enums/exit_status.in
25+++ b/enums/exit_status.in
26@@ -18,3 +18,6 @@ listen_fd, "server loop had no valid listen fd"
27 pseudo_loaded, "server couldn't get out of pseudo environment"
28 pseudo_prefix, "couldn't get valid pseudo prefix"
29 pseudo_invocation, "invalid server command arguments"
30+epoll_create, "epoll_create() failed"
31+epoll_ctl, "epoll_ctl() failed"
32+
33diff --git a/pseudo_server.c b/pseudo_server.c
34index ff16efd..14d34de 100644
35--- a/pseudo_server.c
36+++ b/pseudo_server.c
37@@ -40,6 +40,12 @@
38 #include "pseudo_client.h"
39 #include "pseudo_db.h"
40
41+// This has to come after pseudo includes, as that's where PSEUDO_PORT defines are
42+#ifdef PSEUDO_PORT_LINUX
43+#include <sys/epoll.h>
44+#endif
45+
46+
47 static int listen_fd = -1;
48
49 typedef struct {
50@@ -59,6 +65,7 @@ static int active_clients = 0, highest_client = 0, max_clients = 0;
51
52 #define LOOP_DELAY 2
53 #define DEFAULT_PSEUDO_SERVER_TIMEOUT 30
54+#define EPOLL_MAX_EVENTS 10
55 int pseudo_server_timeout = DEFAULT_PSEUDO_SERVER_TIMEOUT;
56 static int die_peacefully = 0;
57 static int die_forcefully = 0;
58@@ -80,6 +87,9 @@ quit_now(int signal) {
59 static int messages = 0, responses = 0;
60 static struct timeval message_time = { .tv_sec = 0 };
61
62+#ifdef PSEUDO_PORT_LINUX
63+static void pseudo_server_loop_epoll(void);
64+#endif
65 static void pseudo_server_loop(void);
66
67 /* helper function to make a directory, just like mkdir -p.
68@@ -369,12 +379,16 @@ pseudo_server_start(int daemonize) {
69 kill(ppid, SIGUSR1);
70 }
71 }
72+#ifdef PSEUDO_PORT_LINUX
73+ pseudo_server_loop_epoll();
74+#else
75 pseudo_server_loop();
76+#endif
77 return 0;
78 }
79
80 /* mess with internal tables as needed */
81-static void
82+static unsigned int
83 open_client(int fd) {
84 pseudo_client_t *new_clients;
85 int i;
86@@ -390,7 +404,7 @@ open_client(int fd) {
87 ++active_clients;
88 if (i > highest_client)
89 highest_client = i;
90- return;
91+ return i;
92 }
93 }
94
95@@ -414,9 +428,11 @@ open_client(int fd) {
96
97 max_clients += 16;
98 ++active_clients;
99+ return max_clients - 16;
100 } else {
101 pseudo_diag("error allocating new client, fd %d\n", fd);
102 close(fd);
103+ return 0;
104 }
105 }
106
107@@ -433,6 +449,10 @@ close_client(int client) {
108 client, highest_client);
109 return;
110 }
111+ if (clients[client].fd == -1) {
112+ pseudo_debug(PDBGF_SERVER, "client %d already closed\n", client);
113+ return;
114+ }
115 close(clients[client].fd);
116 clients[client].fd = -1;
117 free(clients[client].tag);
118@@ -566,6 +586,171 @@ serve_client(int i) {
119 }
120 }
121
122+#ifdef PSEUDO_PORT_LINUX
123+static void pseudo_server_loop_epoll(void)
124+{
125+ struct sockaddr_un client;
126+ socklen_t len;
127+ int i;
128+ int rc;
129+ int fd;
130+ int timeout;
131+ struct epoll_event ev, events[EPOLL_MAX_EVENTS];
132+ int loop_timeout = pseudo_server_timeout;
133+
134+ clients = malloc(16 * sizeof(*clients));
135+
136+ clients[0].fd = listen_fd;
137+ clients[0].pid = getpid();
138+
139+ for (i = 1; i < 16; ++i) {
140+ clients[i].fd = -1;
141+ clients[i].pid = 0;
142+ clients[i].tag = NULL;
143+ clients[i].program = NULL;
144+ }
145+
146+ active_clients = 1;
147+ max_clients = 16;
148+ highest_client = 0;
149+
150+ pseudo_debug(PDBGF_SERVER, "server loop started.\n");
151+ if (listen_fd < 0) {
152+ pseudo_diag("got into loop with no valid listen fd.\n");
153+ exit(PSEUDO_EXIT_LISTEN_FD);
154+ }
155+
156+ timeout = LOOP_DELAY * 1000;
157+
158+ int epollfd = epoll_create1(0);
159+ if (epollfd == -1) {
160+ pseudo_diag("epoll_create1() failed.\n");
161+ exit(PSEUDO_EXIT_EPOLL_CREATE);
162+ }
163+ ev.events = EPOLLIN;
164+ ev.data.u64 = 0;
165+ if (epoll_ctl(epollfd, EPOLL_CTL_ADD, clients[0].fd, &ev) == -1) {
166+ pseudo_diag("epoll_ctl() failed with listening socket.\n");
167+ exit(PSEUDO_EXIT_EPOLL_CTL);
168+ }
169+
170+ pdb_log_msg(SEVERITY_INFO, NULL, NULL, NULL, "server started (pid %d)", getpid());
171+
172+ for (;;) {
173+ rc = epoll_wait(epollfd, events, EPOLL_MAX_EVENTS, timeout);
174+ if (rc == 0 || (rc == -1 && errno == EINTR)) {
175+ /* If there's no clients, start timing out. If there
176+ * are active clients, never time out.
177+ */
178+ if (active_clients == 1) {
179+ loop_timeout -= LOOP_DELAY;
180+ /* maybe flush database to disk */
181+ pdb_maybe_backup();
182+ if (loop_timeout <= 0) {
183+ pseudo_debug(PDBGF_SERVER, "no more clients, got bored.\n");
184+ die_peacefully = 1;
185+ } else {
186+ /* display this if not exiting */
187+ pseudo_debug(PDBGF_SERVER | PDBGF_BENCHMARK, "%d messages handled in %.4f seconds, %d responses\n",
188+ messages,
189+ (double) message_time.tv_sec +
190+ (double) message_time.tv_usec / 1000000.0,
191+ responses);
192+ }
193+ }
194+ } else if (rc > 0) {
195+ loop_timeout = pseudo_server_timeout;
196+ for (i = 0; i < rc; ++i) {
197+ if (clients[events[i].data.u64].fd == listen_fd) {
198+ if (!die_forcefully) {
199+ len = sizeof(client);
200+ if ((fd = accept(listen_fd, (struct sockaddr *) &client, &len)) != -1) {
201+ /* Don't allow clients to end up on fd 2, because glibc's
202+ * malloc debug uses that fd unconditionally.
203+ */
204+ if (fd == 2) {
205+ int newfd = fcntl(fd, F_DUPFD, 3);
206+ close(fd);
207+ fd = newfd;
208+ }
209+ pseudo_debug(PDBGF_SERVER, "new client fd %d\n", fd);
210+ /* A new client implicitly cancels any
211+ * previous shutdown request, or a
212+ * shutdown for lack of clients.
213+ */
214+ pseudo_server_timeout = DEFAULT_PSEUDO_SERVER_TIMEOUT;
215+ die_peacefully = 0;
216+
217+ ev.events = EPOLLIN;
218+ ev.data.u64 = open_client(fd);
219+ if (ev.data.u64 != 0 && epoll_ctl(epollfd, EPOLL_CTL_ADD, clients[ev.data.u64].fd, &ev) == -1) {
220+ pseudo_diag("epoll_ctl() failed with accepted socket.\n");
221+ exit(PSEUDO_EXIT_EPOLL_CTL);
222+ }
223+ } else if (errno == EMFILE) {
224+ pseudo_debug(PDBGF_SERVER, "Hit max open files, dropping a client.\n");
225+ /* In theory there is a potential race here where if we close a client,
226+ it may have sent us a fastop message which we don't act upon.
227+ If we don't close a filehandle we'll loop indefinitely thought.
228+ Only close one per loop iteration in the interests of caution */
229+ for (int j = 1; j <= highest_client; ++j) {
230+ if (clients[j].fd != -1) {
231+ close_client(j);
232+ break;
233+ }
234+ }
235+ }
236+ }
237+ } else {
238+ struct timeval tv1, tv2;
239+ int rc;
240+ gettimeofday(&tv1, NULL);
241+ rc = serve_client(events[i].data.u64);
242+ gettimeofday(&tv2, NULL);
243+ ++messages;
244+ if (rc == 0)
245+ ++responses;
246+ message_time.tv_sec += (tv2.tv_sec - tv1.tv_sec);
247+ message_time.tv_usec += (tv2.tv_usec - tv1.tv_usec);
248+ if (message_time.tv_usec < 0) {
249+ message_time.tv_usec += 1000000;
250+ --message_time.tv_sec;
251+ } else while (message_time.tv_usec > 1000000) {
252+ message_time.tv_usec -= 1000000;
253+ ++message_time.tv_sec;
254+ }
255+ }
256+ if (die_forcefully)
257+ break;
258+ }
259+ pseudo_debug(PDBGF_SERVER, "server loop complete [%d clients left]\n", active_clients);
260+ } else {
261+ pseudo_diag("epoll_wait failed: %s\n", strerror(errno));
262+ break;
263+ }
264+ if (die_peacefully || die_forcefully) {
265+ pseudo_debug(PDBGF_SERVER, "quitting.\n");
266+ pseudo_debug(PDBGF_SERVER | PDBGF_BENCHMARK, "server %d exiting: handled %d messages in %.4f seconds\n",
267+ getpid(), messages,
268+ (double) message_time.tv_sec +
269+ (double) message_time.tv_usec / 1000000.0);
270+ pdb_log_msg(SEVERITY_INFO, NULL, NULL, NULL, "server %d exiting: handled %d messages in %.4f seconds",
271+ getpid(), messages,
272+ (double) message_time.tv_sec +
273+ (double) message_time.tv_usec / 1000000.0);
274+ /* and at this point, we'll start refusing connections */
275+ close(clients[0].fd);
276+ /* This is a good place to insert a delay for
277+ * debugging race conditions during startup. */
278+ /* usleep(300000); */
279+ exit(0);
280+ }
281+ }
282+
283+}
284+
285+#endif
286+
287 /* get clients, handle messages, shut down.
288 * This doesn't actually do any work, it just calls a ton of things which
289 * do work.
290--
2912.14.1
292
diff --git a/meta/recipes-devtools/pseudo/files/b6b68db896f9963558334aff7fca61adde4ec10f.patch b/meta/recipes-devtools/pseudo/files/b6b68db896f9963558334aff7fca61adde4ec10f.patch
deleted file mode 100644
index 3045a3b736..0000000000
--- a/meta/recipes-devtools/pseudo/files/b6b68db896f9963558334aff7fca61adde4ec10f.patch
+++ /dev/null
@@ -1,48 +0,0 @@
1From b6b68db896f9963558334aff7fca61adde4ec10f Mon Sep 17 00:00:00 2001
2From: Seebs <seebs@seebs.net>
3Date: Thu, 13 Apr 2017 18:12:01 -0500
4Subject: Prevent bash from segfaulting when unloading pseudo
5
6bash's extremely fancy internal awareness of how the environment looks
7means that, if you directly call the underlying libc "unsetenv" on
8a variable, bash can end up trying to access a null pointer. Fixing
9this generically is actually rather hard; you can't really avoid
10writing to environ on fork() or popen(), even if you change all
11execv*() functions to use the execv*e() variants. So for now, instead
12of unsetting the variable, set it to an empty string.
13
14Thanks to Saur in IRC for spotting this and helping debug it.
15
16Signed-off-by: Seebs <seebs@seebs.net>
17
18Upstream-Status: Backport
19
20diff --git a/ChangeLog.txt b/ChangeLog.txt
21index a2d30e9..8ba1ffa 100644
22--- a/ChangeLog.txt
23+++ b/ChangeLog.txt
24@@ -1,3 +1,8 @@
25+2017-04-13:
26+ * (seebs) don't unset LD_PRELOAD or the like, because if you
27+ do that, bash can segfault because it "knows" how many
28+ fields are in environ.
29+
30 2017-02-24:
31 * (seebs) import posix_acl_default fix from Anton Gerasimov
32 <anton@advancedtelematic.com>
33diff --git a/pseudo_util.c b/pseudo_util.c
34index 172990b..6a1fac2 100644
35--- a/pseudo_util.c
36+++ b/pseudo_util.c
37@@ -844,7 +844,7 @@ void pseudo_dropenv() {
38 if (ld_preload && strlen(ld_preload)) {
39 SETENV(PRELINK_LIBRARIES, ld_preload, 1);
40 } else {
41- UNSETENV(PRELINK_LIBRARIES);
42+ SETENV(PRELINK_LIBRARIES, "", 1);
43 }
44 }
45 }
46--
47cgit v0.10.2
48
diff --git a/meta/recipes-devtools/pseudo/files/efe0be279901006f939cd357ccee47b651c786da.patch b/meta/recipes-devtools/pseudo/files/efe0be279901006f939cd357ccee47b651c786da.patch
deleted file mode 100644
index 64fc58c4fe..0000000000
--- a/meta/recipes-devtools/pseudo/files/efe0be279901006f939cd357ccee47b651c786da.patch
+++ /dev/null
@@ -1,99 +0,0 @@
1From efe0be279901006f939cd357ccee47b651c786da Mon Sep 17 00:00:00 2001
2From: Seebs <seebs@seebs.net>
3Date: Fri, 24 Feb 2017 12:47:38 -0600
4Subject: Don't try to record 0-length posix_acl_default xattrs
5
6Based on a submission from Anton Gerasimov <anton@advancedtelematic.com>
7
8On some systems, with some kernel configs, "cp -a" apparently tries to
9set an empty ACL list, with a valid header but no contents, which causes
10strange and mysterious behavior later if we actually create such an entry.
11So filter that out, also sanity-check a couple of other things.
12
13Signed-off-by: Seebs <seebs@seebs.net>
14
15Upstream-Status: Backport
16
17diff --git a/ChangeLog.txt b/ChangeLog.txt
18index ae2a6e9..a2d30e9 100644
19--- a/ChangeLog.txt
20+++ b/ChangeLog.txt
21@@ -1,3 +1,6 @@
22+2017-02-24:
23+ * (seebs) import posix_acl_default fix from Anton Gerasimov
24+ <anton@advancedtelematic.com>
25 2017-02-01:
26 * (seebs) handle xattr deletion slightly more carefully.
27 * (seebs) tag this as 1.8.2
28diff --git a/ports/linux/xattr/pseudo_wrappers.c b/ports/linux/xattr/pseudo_wrappers.c
29index 46bc053..d69d53e 100644
30--- a/ports/linux/xattr/pseudo_wrappers.c
31+++ b/ports/linux/xattr/pseudo_wrappers.c
32@@ -62,9 +62,9 @@ static int
33 posix_permissions(const acl_header *header, int entries, int *extra, int *mode) {
34 int acl_seen = 0;
35 if (le32(header->version) != 2) {
36- pseudo_diag("Fatal: ACL support no available for header version %d.\n",
37+ pseudo_diag("Fatal: ACL support not available for header version %d.\n",
38 le32(header->version));
39- return 1;
40+ return -1;
41 }
42 *mode = 0;
43 *extra = 0;
44@@ -140,12 +140,38 @@ static int shared_setxattr(const char *path, int fd, const char *name, const voi
45 pseudo_debug(PDBGF_XATTR, "setxattr(%s [fd %d], %s => '%.*s')\n",
46 path ? path : "<no path>", fd, name, (int) size, (char *) value);
47
48+ /* Filter out erroneous sizes for POSIX ACL
49+ * see posix_acl_xattr_count in include/linux/posix_acl_xattr.h of Linux source code */
50+ /* I don't think there's any posix_acl_* values that aren't in this format */
51+ if (!strncmp(name, "system.posix_acl_", 17)) {
52+ // ACL is corrupt, issue an error
53+ if(size < sizeof(acl_header) || (size - sizeof(acl_header)) % sizeof(acl_entry) != 0) {
54+ pseudo_debug(PDBGF_XATTR, "invalid data size for %s: %d\n",
55+ name, (int) size);
56+ errno = EINVAL;
57+ return -1;
58+ }
59+
60+ // ACL is empty, do nothing
61+ if((size - sizeof(acl_header)) / sizeof(acl_entry) == 0) {
62+ /* on some systems, "cp -a" will attempt to clone the
63+ * posix_acl_default entry for a directory (which would specify
64+ * default ACLs for new files in that directory), but if the
65+ * original was empty, we get a header but no entries. With
66+ * real xattr, that ends up being silently discarded, apparently,
67+ * so we discard it too.
68+ */
69+ pseudo_debug(PDBGF_XATTR, "0-length ACL entry %s.\n", name);
70+ return 0;
71+ }
72+ }
73 /* this may be a plain chmod */
74 if (!strcmp(name, "system.posix_acl_access")) {
75 int extra;
76 int mode;
77 int entries = (size - sizeof(acl_header)) / sizeof(acl_entry);
78- if (!posix_permissions(value, entries, &extra, &mode)) {
79+ int res = posix_permissions(value, entries, &extra, &mode);
80+ if (res == 0) {
81 pseudo_debug(PDBGF_XATTR, "posix_acl_access translated to mode %04o. Remaining attribute(s): %d.\n",
82 mode, extra);
83 buf.st_mode = mode;
84@@ -164,8 +190,12 @@ static int shared_setxattr(const char *path, int fd, const char *name, const voi
85 if (!extra) {
86 return 0;
87 }
88+ } else if (res == -1) {
89+ errno = EOPNOTSUPP;
90+ return -1;
91 }
92 }
93+
94 if (!strcmp(name, "user.pseudo_data")) {
95 pseudo_debug(PDBGF_XATTR | PDBGF_XATTRDB, "user.pseudo_data xattribute does not get to go in database.\n");
96 return -1;
97--
98cgit v0.10.2
99
diff --git a/meta/recipes-devtools/pseudo/files/fastopreply.patch b/meta/recipes-devtools/pseudo/files/fastopreply.patch
deleted file mode 100644
index 904c2d04e6..0000000000
--- a/meta/recipes-devtools/pseudo/files/fastopreply.patch
+++ /dev/null
@@ -1,76 +0,0 @@
1Ensure FASTOP messages get an ACK reply so that the client can be sure the server
2recieved them. This means if connections are terminated, data isn't lost.
3
4RP 2017/9/22
5
6Upstream-Status: Submitted
7
8Index: pseudo-1.8.2/pseudo_client.c
9===================================================================
10--- pseudo-1.8.2.orig/pseudo_client.c
11+++ pseudo-1.8.2/pseudo_client.c
12@@ -1331,21 +1331,19 @@ pseudo_client_request(pseudo_msg_t *msg,
13 * indicating a successful send.
14 */
15 pseudo_debug(PDBGF_CLIENT | PDBGF_VERBOSE, "sent!\n");
16- if (msg->type != PSEUDO_MSG_FASTOP) {
17- response = pseudo_msg_receive(connect_fd);
18- if (!response) {
19- pseudo_debug(PDBGF_CLIENT, "expected response did not occur; retrying\n");
20+ response = pseudo_msg_receive(connect_fd);
21+ if (!response) {
22+ pseudo_debug(PDBGF_CLIENT, "expected response did not occur; retrying\n");
23+ } else {
24+ if (response->type != PSEUDO_MSG_ACK) {
25+ pseudo_debug(PDBGF_CLIENT, "got non-ack response %d\n", response->type);
26+ return 0;
27+ } else if (msg->type != PSEUDO_MSG_FASTOP) {
28+ pseudo_debug(PDBGF_CLIENT | PDBGF_VERBOSE, "got response type %d\n", response->type);
29+ return response;
30 } else {
31- if (response->type != PSEUDO_MSG_ACK) {
32- pseudo_debug(PDBGF_CLIENT, "got non-ack response %d\n", response->type);
33- return 0;
34- } else {
35- pseudo_debug(PDBGF_CLIENT | PDBGF_VERBOSE, "got response type %d\n", response->type);
36- return response;
37- }
38+ return 0;
39 }
40- } else {
41- return 0;
42 }
43 }
44 pseudo_diag("pseudo: server connection persistently failed, aborting.\n");
45Index: pseudo-1.8.2/pseudo_server.c
46===================================================================
47--- pseudo-1.8.2.orig/pseudo_server.c
48+++ pseudo-1.8.2/pseudo_server.c
49@@ -463,6 +463,11 @@ close_client(int client) {
50 --highest_client;
51 }
52
53+static pseudo_msg_t server_fastop_reply = {
54+ .type = PSEUDO_MSG_ACK,
55+ .op = OP_NONE,
56+};
57+
58 /* Actually process a request.
59 */
60 static int
61@@ -515,8 +520,14 @@ serve_client(int i) {
62 * pseudo_server_response.
63 */
64 if (in->type != PSEUDO_MSG_SHUTDOWN) {
65- if (in->type == PSEUDO_MSG_FASTOP)
66+ if (in->type == PSEUDO_MSG_FASTOP) {
67 send_response = 0;
68+ /* For fastops we reply now to say we got the data */
69+ if ((rc = pseudo_msg_send(clients[i].fd, &server_fastop_reply, 0, NULL)) != 0) {
70+ pseudo_debug(PDBGF_SERVER, "failed to send fastop ack to client %d [%d]: %d (%s)\n",
71+ i, (int) clients[i].pid, rc, strerror(errno));
72+ }
73+ }
74 /* most messages don't need these, but xattr may */
75 response_path = 0;
76 response_pathlen = -1;
diff --git a/meta/recipes-devtools/pseudo/files/toomanyfiles.patch b/meta/recipes-devtools/pseudo/files/toomanyfiles.patch
index b085a4505d..bda7e4b202 100644
--- a/meta/recipes-devtools/pseudo/files/toomanyfiles.patch
+++ b/meta/recipes-devtools/pseudo/files/toomanyfiles.patch
@@ -1,3 +1,8 @@
1From b0b25fbc041a148d1de09f5a6503cd95973ec77c Mon Sep 17 00:00:00 2001
2From: Richard Purdie <richard.purdie@linuxfoundation.org>
3Date: Tue, 25 Apr 2017 15:25:54 +0100
4Subject: [PATCH 3/3] pseudo: Handle too many files deadlock
5
1Currently if we max out the maximum number of files, pseudo can deadlock, unable to 6Currently 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 7accept new connections yet unable to move forward and unblock the other processes
3waiting either. 8waiting either.
@@ -11,19 +16,23 @@ RP
11 16
12Upstream-Status: Submitted [Peter is aware of the issue] 17Upstream-Status: Submitted [Peter is aware of the issue]
13 18
14Index: pseudo-1.8.2/pseudo_server.c 19---
15=================================================================== 20 pseudo_server.c | 10 ++++++++++
16--- pseudo-1.8.2.orig/pseudo_server.c 21 1 file changed, 10 insertions(+)
17+++ pseudo-1.8.2/pseudo_server.c 22
18@@ -581,6 +581,7 @@ pseudo_server_loop(void) { 23diff --git a/pseudo_server.c b/pseudo_server.c
19 int rc; 24index dac3258..15a3e8f 100644
20 int fd; 25--- a/pseudo_server.c
21 int loop_timeout = pseudo_server_timeout; 26+++ b/pseudo_server.c
27@@ -802,6 +802,7 @@ pseudo_server_loop(void) {
28 struct sigaction eat_usr2 = {
29 .sa_handler = set_do_list_clients
30 };
22+ int hitmaxfiles; 31+ int hitmaxfiles;
23 32
24 clients = malloc(16 * sizeof(*clients)); 33 clients = malloc(16 * sizeof(*clients));
25 34
26@@ -597,6 +598,7 @@ pseudo_server_loop(void) { 35@@ -820,6 +821,7 @@ pseudo_server_loop(void) {
27 active_clients = 1; 36 active_clients = 1;
28 max_clients = 16; 37 max_clients = 16;
29 highest_client = 0; 38 highest_client = 0;
@@ -31,9 +40,9 @@ Index: pseudo-1.8.2/pseudo_server.c
31 40
32 pseudo_debug(PDBGF_SERVER, "server loop started.\n"); 41 pseudo_debug(PDBGF_SERVER, "server loop started.\n");
33 if (listen_fd < 0) { 42 if (listen_fd < 0) {
34@@ -663,10 +665,15 @@ pseudo_server_loop(void) { 43@@ -878,10 +880,15 @@ pseudo_server_loop(void) {
35 message_time.tv_usec -= 1000000; 44 } else {
36 ++message_time.tv_sec; 45 serve_client(i);
37 } 46 }
38+ } else if (hitmaxfiles) { 47+ } else if (hitmaxfiles) {
39+ /* Only close one per loop iteration in the interests of caution */ 48+ /* Only close one per loop iteration in the interests of caution */
@@ -47,13 +56,16 @@ Index: pseudo-1.8.2/pseudo_server.c
47 if (!die_forcefully && 56 if (!die_forcefully &&
48 (FD_ISSET(clients[0].fd, &events) || 57 (FD_ISSET(clients[0].fd, &events) ||
49 FD_ISSET(clients[0].fd, &reads))) { 58 FD_ISSET(clients[0].fd, &reads))) {
50@@ -688,6 +698,9 @@ pseudo_server_loop(void) { 59@@ -903,6 +910,9 @@ pseudo_server_loop(void) {
51 */ 60 */
52 pseudo_server_timeout = DEFAULT_PSEUDO_SERVER_TIMEOUT; 61 pseudo_server_timeout = DEFAULT_PSEUDO_SERVER_TIMEOUT;
53 die_peacefully = 0; 62 die_peacefully = 0;
54+ } else if (errno == EMFILE) { 63+ } else if (errno == EMFILE) {
55+ hitmaxfiles = 1; 64+ hitmaxfiles = 1;
56+ pseudo_debug(PDBGF_SERVER, "Hit max open files, dropping a client.\n"); 65+ pseudo_debug(PDBGF_SERVER, "Hit max open files, dropping a client.\n");
57 } 66 }
58 } 67 }
59 pseudo_debug(PDBGF_SERVER, "server loop complete [%d clients left]\n", active_clients); 68 pseudo_debug(PDBGF_SERVER, "server loop complete [%d clients left]\n", active_clients);
69--
702.15.1
71
diff --git a/meta/recipes-devtools/pseudo/pseudo.inc b/meta/recipes-devtools/pseudo/pseudo.inc
index 18ce9f9259..fb742522f5 100644
--- a/meta/recipes-devtools/pseudo/pseudo.inc
+++ b/meta/recipes-devtools/pseudo/pseudo.inc
@@ -26,7 +26,7 @@ do_configure () {
26NO32LIBS ??= "1" 26NO32LIBS ??= "1"
27NO32LIBS_class-nativesdk = "1" 27NO32LIBS_class-nativesdk = "1"
28 28
29PSEUDO_EXTRA_OPTS ?= "--enable-force-async --without-passwd-fallback" 29PSEUDO_EXTRA_OPTS ?= "--enable-force-async --without-passwd-fallback --enable-epoll"
30 30
31# Compile for the local machine arch... 31# Compile for the local machine arch...
32do_compile () { 32do_compile () {
diff --git a/meta/recipes-devtools/pseudo/pseudo_1.8.2.bb b/meta/recipes-devtools/pseudo/pseudo_1.8.2.bb
deleted file mode 100644
index 73ef57231a..0000000000
--- a/meta/recipes-devtools/pseudo/pseudo_1.8.2.bb
+++ /dev/null
@@ -1,16 +0,0 @@
1require pseudo.inc
2
3SRC_URI = "http://downloads.yoctoproject.org/releases/pseudo/${BPN}-${PV}.tar.bz2 \
4 file://0001-configure-Prune-PIE-flags.patch \
5 file://fallback-passwd \
6 file://fallback-group \
7 file://moreretries.patch \
8 file://efe0be279901006f939cd357ccee47b651c786da.patch \
9 file://b6b68db896f9963558334aff7fca61adde4ec10f.patch \
10 file://fastopreply.patch \
11 file://toomanyfiles.patch \
12 file://0001-Use-epoll-API-on-Linux.patch \
13 "
14
15SRC_URI[md5sum] = "7d41e72188fbea1f696c399c1a435675"
16SRC_URI[sha256sum] = "ceb456bd47770a37ca20784a91d715c5a7601e07e26ab11b0c77e9203ed3d196"
diff --git a/meta/recipes-devtools/pseudo/pseudo_git.bb b/meta/recipes-devtools/pseudo/pseudo_git.bb
index 42c7b2ea57..66da1cc53b 100644
--- a/meta/recipes-devtools/pseudo/pseudo_git.bb
+++ b/meta/recipes-devtools/pseudo/pseudo_git.bb
@@ -1,15 +1,14 @@
1require pseudo.inc 1require pseudo.inc
2 2
3SRCREV = "02168305b0a19f981ffe857f36eb256ba8810b77"
4PV = "1.8.2+git${SRCPV}"
5
6DEFAULT_PREFERENCE = "-1"
7
8SRC_URI = "git://git.yoctoproject.org/pseudo \ 3SRC_URI = "git://git.yoctoproject.org/pseudo \
9 file://0001-configure-Prune-PIE-flags.patch \ 4 file://0001-configure-Prune-PIE-flags.patch \
10 file://fallback-passwd \ 5 file://fallback-passwd \
11 file://fallback-group \ 6 file://fallback-group \
12 file://moreretries.patch" 7 file://moreretries.patch \
8 file://toomanyfiles.patch \
9 "
13 10
11SRCREV = "d7c31a25e4b02af0c64e6be0b4b0a9ac4ffc9da2"
14S = "${WORKDIR}/git" 12S = "${WORKDIR}/git"
13PV = "1.9.0+git${SRCPV}"
15 14