diff options
author | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2022-06-11 03:09:49 -0500 |
---|---|---|
committer | Zach van Rijn <me@zv.io> | 2022-10-21 18:34:01 -0500 |
commit | 73c30f0daaaef399e095198883215a27dfe509f3 (patch) | |
tree | ed5c1b966bcf39fd46c36703fd92f797457d7196 /user | |
parent | dbe39003ab54ef5afab300c186d1187a6fa822cc (diff) | |
download | packages-73c30f0daaaef399e095198883215a27dfe509f3.tar.gz packages-73c30f0daaaef399e095198883215a27dfe509f3.tar.bz2 packages-73c30f0daaaef399e095198883215a27dfe509f3.tar.xz packages-73c30f0daaaef399e095198883215a27dfe509f3.zip |
user/speech-dispatcher: Work around thread leak
Diffstat (limited to 'user')
-rw-r--r-- | user/speech-dispatcher/APKBUILD | 5 | ||||
-rw-r--r-- | user/speech-dispatcher/threadleak.patch | 84 |
2 files changed, 88 insertions, 1 deletions
diff --git a/user/speech-dispatcher/APKBUILD b/user/speech-dispatcher/APKBUILD index 8c345c08a..cd700a4bf 100644 --- a/user/speech-dispatcher/APKBUILD +++ b/user/speech-dispatcher/APKBUILD @@ -14,6 +14,7 @@ makedepends="alsa-lib-dev dotconf-dev flite-dev glib-dev intltool subpackages="$pkgname-dev $pkgname-doc $pkgname-lang" source="https://github.com/brailcom/speechd/releases/download/$pkgver/speech-dispatcher-$pkgver.tar.gz sys-types.patch + threadleak.patch " build() { @@ -39,4 +40,6 @@ package() { } sha512sums="859911d7db5660423bc7911eacbe8e7a9c3104df97478cbbca48ca5fd6ec018113172d49bc66781680433c77b4d2af43578c9b0f11409e2ba7ac618deb31d7cf speech-dispatcher-0.11.1.tar.gz -111562b044834189016a0328240f1bc97c38461fb07677b9c6ae36b97b2ddcf3b30c9ac5b8ab6e69209afb8e4e9b6ca13373a685c840be9ba301e1ef270f1a99 sys-types.patch" +111562b044834189016a0328240f1bc97c38461fb07677b9c6ae36b97b2ddcf3b30c9ac5b8ab6e69209afb8e4e9b6ca13373a685c840be9ba301e1ef270f1a99 sys-types.patch +201e9c1453eb6025e4385173b8068fa8198087d5006f5e90814198b271f7a49aa204235ca7ed521757702e72531678f9cade793d5f4ef1e211122cb9aaf99caa threadleak.patch +ecab7c0bbddf2f6419585a452f5a9c9c74f17784869ac46c5f9708162885c58778cbdaff918e3e4f3f3ae84b1cacdf4480b9664a17f817c3722636eb3f028462 test.patch" diff --git a/user/speech-dispatcher/threadleak.patch b/user/speech-dispatcher/threadleak.patch new file mode 100644 index 000000000..6983a6dab --- /dev/null +++ b/user/speech-dispatcher/threadleak.patch @@ -0,0 +1,84 @@ +From a054e9469dd6481e24c385162013fc14fefb940f Mon Sep 17 00:00:00 2001 +From: Samuel Thibault <samuel.thibault@ens-lyon.org> +Date: Sun, 13 Mar 2022 17:04:09 +0100 +Subject: [PATCH] libspeechd: Fix memleak when using threaded mode + +--- + src/api/c/libspeechd.c | 36 ++++++++++++++++++++++++++---------- + 1 file changed, 26 insertions(+), 10 deletions(-) + +diff --git a/src/api/c/libspeechd.c b/src/api/c/libspeechd.c +index b0f30286..dd4c7f7b 100644 +--- a/src/api/c/libspeechd.c ++++ b/src/api/c/libspeechd.c +@@ -1777,21 +1777,35 @@ static int spd_set_priority(SPDConnection * connection, SPDPriority priority) + return spd_execute_command_wo_mutex(connection, command); + } + ++struct get_reply_data { ++ GString *str; ++ char *line; ++}; ++ ++static void get_reply_cleanup(void *arg) ++{ ++ struct get_reply_data *data = arg; ++ g_string_free(data->str, TRUE); ++ free(data->line); ++} ++ + static char *get_reply(SPDConnection * connection) + { +- GString *str; +- char *line = NULL; + size_t N = 0; + int bytes; + char *reply; + gboolean errors = FALSE; ++ struct get_reply_data data; + +- str = g_string_new(""); ++ data.line = NULL; ++ data.str = g_string_new(""); ++ ++ pthread_cleanup_push(get_reply_cleanup, &data); + + /* Wait for activity on the socket, when there is some, + read all the message line by line */ + do { +- bytes = getline(&line, &N, connection->stream); ++ bytes = getline(&data.line, &N, connection->stream); + if (bytes == -1) { + SPD_DBG + ("Error: Can't read reply, broken socket in get_reply!"); +@@ -1800,22 +1814,24 @@ static char *get_reply(SPDConnection * connection) + connection->stream = NULL; + errors = TRUE; + } else { +- g_string_append(str, line); ++ g_string_append(data.str, data.line); + } + /* terminate if we reached the last line (without '-' after numcode) */ +- } while (!errors && !((strlen(line) < 4) || (line[3] == ' '))); ++ } while (!errors && !((strlen(data.line) < 4) || (data.line[3] == ' '))); ++ ++ pthread_cleanup_pop(0); + +- free(line); /* getline allocates with malloc. */ ++ free(data.line); /* getline allocates with malloc. */ + + if (errors) { + /* Free the GString and its character data, and return NULL. */ +- g_string_free(str, TRUE); ++ g_string_free(data.str, TRUE); + reply = NULL; + } else { + /* The resulting message received from the socket is stored in reply */ +- reply = str->str; ++ reply = data.str->str; + /* Free the GString, but not its character data. */ +- g_string_free(str, FALSE); ++ g_string_free(data.str, FALSE); + } + + return reply; |