diff options
Diffstat (limited to 'meta/recipes-devtools/pseudo/files/toomanyfiles.patch')
| -rw-r--r-- | meta/recipes-devtools/pseudo/files/toomanyfiles.patch | 71 |
1 files changed, 0 insertions, 71 deletions
diff --git a/meta/recipes-devtools/pseudo/files/toomanyfiles.patch b/meta/recipes-devtools/pseudo/files/toomanyfiles.patch deleted file mode 100644 index bda7e4b202..0000000000 --- a/meta/recipes-devtools/pseudo/files/toomanyfiles.patch +++ /dev/null | |||
| @@ -1,71 +0,0 @@ | |||
| 1 | From b0b25fbc041a148d1de09f5a6503cd95973ec77c Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Richard Purdie <richard.purdie@linuxfoundation.org> | ||
| 3 | Date: Tue, 25 Apr 2017 15:25:54 +0100 | ||
| 4 | Subject: [PATCH 3/3] pseudo: Handle too many files deadlock | ||
| 5 | |||
| 6 | Currently if we max out the maximum number of files, pseudo can deadlock, unable to | ||
| 7 | accept new connections yet unable to move forward and unblock the other processes | ||
| 8 | waiting either. | ||
| 9 | |||
| 10 | Rather than hang, when this happens, close out inactive connections, allowing us | ||
| 11 | to accept the new ones. The disconnected clients will simply reconnect. There is | ||
| 12 | a small risk of data loss here sadly but its better than hanging. | ||
| 13 | |||
| 14 | RP | ||
| 15 | 2017/4/25 | ||
| 16 | |||
| 17 | Upstream-Status: Submitted [Peter is aware of the issue] | ||
| 18 | |||
| 19 | --- | ||
| 20 | pseudo_server.c | 10 ++++++++++ | ||
| 21 | 1 file changed, 10 insertions(+) | ||
| 22 | |||
| 23 | diff --git a/pseudo_server.c b/pseudo_server.c | ||
| 24 | index dac3258..15a3e8f 100644 | ||
| 25 | --- a/pseudo_server.c | ||
| 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 | }; | ||
| 31 | + int hitmaxfiles; | ||
| 32 | |||
| 33 | clients = malloc(16 * sizeof(*clients)); | ||
| 34 | |||
| 35 | @@ -820,6 +821,7 @@ pseudo_server_loop(void) { | ||
| 36 | active_clients = 1; | ||
| 37 | max_clients = 16; | ||
| 38 | highest_client = 0; | ||
| 39 | + hitmaxfiles = 0; | ||
| 40 | |||
| 41 | pseudo_debug(PDBGF_SERVER, "server loop started.\n"); | ||
| 42 | if (listen_fd < 0) { | ||
| 43 | @@ -878,10 +880,15 @@ pseudo_server_loop(void) { | ||
| 44 | } else { | ||
| 45 | serve_client(i); | ||
| 46 | } | ||
| 47 | + } else if (hitmaxfiles) { | ||
| 48 | + /* Only close one per loop iteration in the interests of caution */ | ||
| 49 | + close_client(i); | ||
| 50 | + hitmaxfiles = 0; | ||
| 51 | } | ||
| 52 | if (die_forcefully) | ||
| 53 | break; | ||
| 54 | } | ||
| 55 | + hitmaxfiles = 0; | ||
| 56 | if (!die_forcefully && | ||
| 57 | (FD_ISSET(clients[0].fd, &events) || | ||
| 58 | FD_ISSET(clients[0].fd, &reads))) { | ||
| 59 | @@ -903,6 +910,9 @@ pseudo_server_loop(void) { | ||
| 60 | */ | ||
| 61 | pseudo_server_timeout = DEFAULT_PSEUDO_SERVER_TIMEOUT; | ||
| 62 | die_peacefully = 0; | ||
| 63 | + } else if (errno == EMFILE) { | ||
| 64 | + hitmaxfiles = 1; | ||
| 65 | + pseudo_debug(PDBGF_SERVER, "Hit max open files, dropping a client.\n"); | ||
| 66 | } | ||
| 67 | } | ||
| 68 | pseudo_debug(PDBGF_SERVER, "server loop complete [%d clients left]\n", active_clients); | ||
| 69 | -- | ||
| 70 | 2.15.1 | ||
| 71 | |||
