Gentoo Archives: gentoo-commits

From: Marek Szuba <marecki@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: net-misc/asterisk/, profiles/, net-misc/asterisk/files/
Date: Wed, 23 Dec 2020 21:31:30
Message-Id: 1608759075.a3cafd53b24a1a01b8ef2add7e91896e80c16ca3.marecki@gentoo
1 commit: a3cafd53b24a1a01b8ef2add7e91896e80c16ca3
2 Author: Jaco Kroon <jaco <AT> uls <DOT> co <DOT> za>
3 AuthorDate: Wed Dec 23 19:20:15 2020 +0000
4 Commit: Marek Szuba <marecki <AT> gentoo <DOT> org>
5 CommitDate: Wed Dec 23 21:31:15 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a3cafd53
7
8 net-misc/asterisk: bumps for SLOTed lua and func_lock races.
9
10 1. Alternate patch for LUA, also upstream:
11 https://gerrit.asterisk.org/c/asterisk/+/15234
12 2. Include LOCK(),TRYLOCK and UNLOCK() fixes:
13 https://gerrit.asterisk.org/c/asterisk/+/15227
14
15 Closes: https://github.com/gentoo/gentoo/pull/18410
16 Signed-off-by: Jaco Kroon <jaco <AT> uls.co.za>
17 Signed-off-by: Marek Szuba <marecki <AT> gentoo.org>
18
19 ...14.0-r100.ebuild => asterisk-13.38.1-r1.ebuild} | 27 +-
20 ...14.0-r100.ebuild => asterisk-16.15.1-r1.ebuild} | 8 +-
21 .../asterisk-13.38.1-r1-autoconf-lua-version.patch | 56 ++++
22 .../asterisk-13.38.1-r1-func_lock-fix-races.patch | 291 +++++++++++++++++++++
23 .../asterisk-16.14.0-autoconf-lua-version.patch | 31 ---
24 profiles/package.mask | 3 +-
25 6 files changed, 366 insertions(+), 50 deletions(-)
26
27 diff --git a/net-misc/asterisk/asterisk-16.14.0-r100.ebuild b/net-misc/asterisk/asterisk-13.38.1-r1.ebuild
28 similarity index 94%
29 copy from net-misc/asterisk/asterisk-16.14.0-r100.ebuild
30 copy to net-misc/asterisk/asterisk-13.38.1-r1.ebuild
31 index 43d3c3dcdb5..7fd03e6fd84 100644
32 --- a/net-misc/asterisk/asterisk-16.14.0-r100.ebuild
33 +++ b/net-misc/asterisk/asterisk-13.38.1-r1.ebuild
34 @@ -3,7 +3,7 @@
35
36 EAPI=7
37
38 -LUA_COMPAT=( lua5-{1..3} )
39 +LUA_COMPAT=( lua5-{1..4} )
40
41 inherit autotools linux-info lua-single systemd
42
43 @@ -20,7 +20,7 @@ IUSE_VOICEMAIL_STORAGE="
44 voicemail_storage_odbc
45 voicemail_storage_imap
46 "
47 -IUSE="${IUSE_VOICEMAIL_STORAGE} alsa bluetooth calendar +caps cluster curl dahdi debug doc freetds gtalk http iconv ilbc ldap libressl lua mysql newt odbc oss pjproject portaudio postgres radius selinux snmp span speex srtp +ssl static statsd syslog unbound vorbis xmpp"
48 +IUSE="${IUSE_VOICEMAIL_STORAGE} alsa bluetooth calendar +caps cluster curl dahdi debug doc freetds gtalk http iconv ilbc ldap libressl lua mysql newt odbc oss pjproject portaudio postgres radius selinux snmp span speex srtp +ssl static statsd syslog vorbis xmpp"
49 IUSE_EXPAND="VOICEMAIL_STORAGE"
50 REQUIRED_USE="gtalk? ( xmpp )
51 lua? ( ${LUA_REQUIRED_USE} )
52 @@ -30,18 +30,18 @@ REQUIRED_USE="gtalk? ( xmpp )
53
54 PATCHES=(
55 "${FILESDIR}/${PN}-historic-no-var-run-install.patch"
56 - "${FILESDIR}/${PN}-16.14.0-autoconf-lua-version.patch"
57 + "${FILESDIR}/${PN}-13.38.1-r1-autoconf-lua-version.patch"
58 + "${FILESDIR}/${PN}-13.38.1-r1-func_lock-fix-races.patch"
59 )
60
61 DEPEND="acct-user/asterisk
62 acct-group/asterisk
63 dev-db/sqlite:3
64 dev-libs/popt
65 - >=dev-libs/jansson-2.11
66 + dev-libs/jansson
67 dev-libs/libedit
68 dev-libs/libxml2:2
69 dev-libs/libxslt
70 - sys-apps/util-linux
71 sys-libs/ncurses:0=
72 sys-libs/zlib
73 alsa? ( media-libs/alsa-lib )
74 @@ -68,7 +68,7 @@ DEPEND="acct-user/asterisk
75 mysql? ( dev-db/mysql-connector-c:= )
76 newt? ( dev-libs/newt )
77 odbc? ( dev-db/unixODBC )
78 - pjproject? ( >=net-libs/pjproject-2.9 )
79 + pjproject? ( net-libs/pjproject )
80 portaudio? ( media-libs/portaudio )
81 postgres? ( dev-db/postgresql:* )
82 radius? ( net-dialup/freeradius-client )
83 @@ -84,7 +84,6 @@ DEPEND="acct-user/asterisk
84 !libressl? ( dev-libs/openssl:0= )
85 libressl? ( dev-libs/libressl:0= )
86 )
87 - unbound? ( net-dns/unbound )
88 vorbis? (
89 media-libs/libogg
90 media-libs/libvorbis
91 @@ -123,7 +122,7 @@ src_configure() {
92 local vmst
93
94 econf \
95 - LUA_IMPL="${ELUA}" \
96 + LUA_VERSION="${ELUA#lua}" \
97 --libdir="/usr/$(get_libdir)" \
98 --localstatedir="/var" \
99 --with-crypto \
100 @@ -131,22 +130,20 @@ src_configure() {
101 --with-popt \
102 --with-z \
103 --with-libedit \
104 - --without-jansson-bundled \
105 - --without-pjproject-bundled \
106 $(use_with caps cap) \
107 + $(use_with lua lua) \
108 $(use_with http gmime) \
109 $(use_with newt) \
110 $(use_with pjproject) \
111 $(use_with portaudio) \
112 - $(use_with ssl) \
113 - $(use_with unbound)
114 + $(use_with ssl)
115
116 _menuselect() {
117 menuselect/menuselect "$@" || die "menuselect $* failed."
118 }
119
120 _use_select() {
121 - local state=$(use "$1" && echo enable || echo disable)
122 + local state=$(usex "$1" enable disable)
123 shift # remove use from parameters
124
125 while [[ -n $1 ]]; do
126 @@ -164,7 +161,7 @@ src_configure() {
127 sed -i 's/NATIVE_ARCH=/NATIVE_ARCH=0/' build_tools/menuselect-deps || die "Unable to squelch noisy build system"
128
129 # Compile menuselect binary for optional components
130 - emake NOISY_BUILD=yes menuselect.makeopts
131 + emake NOISE_BUILD=yes menuselect.makeopts
132
133 # Disable BUILD_NATIVE (bug #667498)
134 _menuselect --disable build_native menuselect.makeopts
135 @@ -231,7 +228,7 @@ src_configure() {
136
137 if use debug; then
138 for o in DONT_OPTIMIZE DEBUG_THREADS BETTER_BACKTRACES; do
139 - _menuselect --enable "${o}" menuselect.makeopts
140 + _menuselect --enable $o menuselect.makeopts
141 done
142 fi
143 }
144
145 diff --git a/net-misc/asterisk/asterisk-16.14.0-r100.ebuild b/net-misc/asterisk/asterisk-16.15.1-r1.ebuild
146 similarity index 97%
147 rename from net-misc/asterisk/asterisk-16.14.0-r100.ebuild
148 rename to net-misc/asterisk/asterisk-16.15.1-r1.ebuild
149 index 43d3c3dcdb5..7259961c65f 100644
150 --- a/net-misc/asterisk/asterisk-16.14.0-r100.ebuild
151 +++ b/net-misc/asterisk/asterisk-16.15.1-r1.ebuild
152 @@ -3,7 +3,7 @@
153
154 EAPI=7
155
156 -LUA_COMPAT=( lua5-{1..3} )
157 +LUA_COMPAT=( lua5-{1..4} )
158
159 inherit autotools linux-info lua-single systemd
160
161 @@ -30,7 +30,8 @@ REQUIRED_USE="gtalk? ( xmpp )
162
163 PATCHES=(
164 "${FILESDIR}/${PN}-historic-no-var-run-install.patch"
165 - "${FILESDIR}/${PN}-16.14.0-autoconf-lua-version.patch"
166 + "${FILESDIR}/${PN}-13.38.1-r1-autoconf-lua-version.patch"
167 + "${FILESDIR}/${PN}-13.38.1-r1-func_lock-fix-races.patch"
168 )
169
170 DEPEND="acct-user/asterisk
171 @@ -123,7 +124,7 @@ src_configure() {
172 local vmst
173
174 econf \
175 - LUA_IMPL="${ELUA}" \
176 + LUA_VERSION="${ELUA#lua}" \
177 --libdir="/usr/$(get_libdir)" \
178 --localstatedir="/var" \
179 --with-crypto \
180 @@ -134,6 +135,7 @@ src_configure() {
181 --without-jansson-bundled \
182 --without-pjproject-bundled \
183 $(use_with caps cap) \
184 + $(use_with lua lua) \
185 $(use_with http gmime) \
186 $(use_with newt) \
187 $(use_with pjproject) \
188
189 diff --git a/net-misc/asterisk/files/asterisk-13.38.1-r1-autoconf-lua-version.patch b/net-misc/asterisk/files/asterisk-13.38.1-r1-autoconf-lua-version.patch
190 new file mode 100644
191 index 00000000000..00a922ce073
192 --- /dev/null
193 +++ b/net-misc/asterisk/files/asterisk-13.38.1-r1-autoconf-lua-version.patch
194 @@ -0,0 +1,56 @@
195 +From 61ef1a71e312f846b08ec4307c449f03907610a6 Mon Sep 17 00:00:00 2001
196 +From: Jaco Kroon <jaco@××××××.za>
197 +Date: Wed, 23 Dec 2020 19:41:10 +0200
198 +Subject: [PATCH] pbx_lua: Add LUA_VERSION environment variable to
199 + ./configure.
200 +
201 +On Gentoo it's possible to have multiple lua versions installed, all
202 +with a path of /usr, so it's not possible to use the current --with-lua
203 +option to determisticly pin to a specific version as is required by the
204 +Gentoo PMS standards.
205 +
206 +This environment variable allows to lock to specific versions,
207 +unversioned check will be skipped if this variable is supplied.
208 +
209 +Change-Id: I8c403eda05df25ee0193960262ce849c7d2fd088
210 +Signed-off-by: Jaco Kroon <jaco@××××××.za>
211 +---
212 + configure | 7 ++++++-
213 + configure.ac | 7 +++++--
214 + 2 files changed, 11 insertions(+), 3 deletions(-)
215 +
216 +diff --git a/configure.ac b/configure.ac
217 +index 64a0a5ace5..b380759b2b 100644
218 +--- a/configure.ac
219 ++++ b/configure.ac
220 +@@ -511,6 +511,7 @@ AST_EXT_LIB_SETUP([LIBXML2], [LibXML2], [libxml2])
221 + AST_EXT_LIB_SETUP([LIBXSLT], [LibXSLT], [libxslt])
222 + AST_EXT_LIB_SETUP_OPTIONAL([LIBXSLT_CLEANUP], [LibXSLT Library Cleanup Function], [LIBXSLT], [libxslt])
223 + AST_EXT_LIB_SETUP([LUA], [Lua], [lua])
224 ++AC_ARG_VAR([LUA_VERSION],[A space separated list of target lua versions to test.])
225 + AST_EXT_LIB_SETUP([MISDN], [mISDN user], [misdn])
226 + AST_EXT_LIB_SETUP([MYSQLCLIENT], [MySQL client], [mysqlclient])
227 + AST_EXT_LIB_SETUP([NBS], [Network Broadcast Sound], [nbs])
228 +@@ -2559,7 +2560,7 @@ if test -z "$__opus_include" -o x"$__opus_include" = x" " ; then
229 + fi
230 + AST_EXT_LIB_CHECK([OPUSFILE], [opusfile], [op_open_callbacks], [opus/opusfile.h], [], [$__opus_include])
231 +
232 +-for ver in 5.4 5.3 5.2 5.1; do
233 ++for ver in ${LUA_VERSION:-5.4 5.3 5.2 5.1}; do
234 + AST_EXT_LIB_CHECK([LUA], lua${ver}, [luaL_newstate], lua${ver}/lua.h, [-lm])
235 + if test "x${PBX_LUA}" = "x1" ; then
236 + if test x"${LUA_DIR}" = x; then
237 +@@ -2572,7 +2573,9 @@ for ver in 5.4 5.3 5.2 5.1; do
238 + done
239 +
240 + # Some distributions (like openSUSE and NetBSD) remove the 5.x suffix.
241 +-AST_EXT_LIB_CHECK([LUA], [lua], [luaL_newstate], [lua.h], [-lm])
242 ++if test "x${LUA_VERSION}" = "x"; then
243 ++ AST_EXT_LIB_CHECK([LUA], [lua], [luaL_newstate], [lua.h], [-lm])
244 ++fi
245 +
246 + # Accept either RADIUS client library, their APIs are fully compatible,
247 + # just different header filenames and different SONAMEs
248 +--
249 +2.26.2
250 +
251
252 diff --git a/net-misc/asterisk/files/asterisk-13.38.1-r1-func_lock-fix-races.patch b/net-misc/asterisk/files/asterisk-13.38.1-r1-func_lock-fix-races.patch
253 new file mode 100644
254 index 00000000000..b8b98e4929b
255 --- /dev/null
256 +++ b/net-misc/asterisk/files/asterisk-13.38.1-r1-func_lock-fix-races.patch
257 @@ -0,0 +1,291 @@
258 +From 8ec686ebb4fa68512ca2dfe40b117523074aed0f Mon Sep 17 00:00:00 2001
259 +From: Jaco Kroon <jaco@××××××.za>
260 +Date: Fri, 18 Dec 2020 21:06:20 +0200
261 +Subject: [PATCH] func_lock: fix multiple-channel-grant problems.
262 +
263 +Under contention it becomes possible that multiple channels will be told
264 +they successfully obtained the lock, which is a bug. Please refer
265 +
266 +ASTERISK-29217
267 +
268 +This introduces a couple of changes.
269 +
270 +1. Replaces requesters ao2 container with simple counter (we don't
271 + really care who is waiting for the lock, only how many). This is
272 + updated undex ->mutex to prevent memory access races.
273 +2. Correct semantics for ast_cond_timedwait() as described in
274 + pthread_cond_broadcast(3P) is used (multiple threads can be released
275 + on a single _signal()).
276 +3. Module unload races are taken care of and memory properly cleaned
277 + up.
278 +
279 +Change-Id: I6f68b5ec82ff25b2909daf6e4d19ca864a463e29
280 +Signed-off-by: Jaco Kroon <jaco@××××××.za>
281 +---
282 + funcs/func_lock.c | 163 ++++++++++++++++------------------------------
283 + 1 file changed, 56 insertions(+), 107 deletions(-)
284 +
285 +diff --git a/funcs/func_lock.c b/funcs/func_lock.c
286 +index acb5fc935c..072640751e 100644
287 +--- a/funcs/func_lock.c
288 ++++ b/funcs/func_lock.c
289 +@@ -110,7 +110,6 @@ static AST_LIST_HEAD_STATIC(locklist, lock_frame);
290 + static void lock_free(void *data);
291 + static void lock_fixup(void *data, struct ast_channel *oldchan, struct ast_channel *newchan);
292 + static int unloading = 0;
293 +-static pthread_t broker_tid = AST_PTHREADT_NULL;
294 +
295 + static const struct ast_datastore_info lock_info = {
296 + .type = "MUTEX",
297 +@@ -124,8 +123,8 @@ struct lock_frame {
298 + ast_cond_t cond;
299 + /*! count is needed so if a recursive mutex exits early, we know how many times to unlock it. */
300 + unsigned int count;
301 +- /*! Container of requesters for the named lock */
302 +- struct ao2_container *requesters;
303 ++ /*! Count of waiting of requesters for the named lock */
304 ++ unsigned int requesters;
305 + /*! who owns us */
306 + struct ast_channel *owner;
307 + /*! name of the lock */
308 +@@ -147,8 +146,11 @@ static void lock_free(void *data)
309 + while ((clframe = AST_LIST_REMOVE_HEAD(oldlist, list))) {
310 + /* Only unlock if we own the lock */
311 + if (clframe->channel == clframe->lock_frame->owner) {
312 ++ ast_mutex_lock(&clframe->lock_frame->mutex);
313 + clframe->lock_frame->count = 0;
314 + clframe->lock_frame->owner = NULL;
315 ++ ast_cond_signal(&clframe->lock_frame->cond);
316 ++ ast_mutex_unlock(&clframe->lock_frame->mutex);
317 + }
318 + ast_free(clframe);
319 + }
320 +@@ -173,54 +175,11 @@ static void lock_fixup(void *data, struct ast_channel *oldchan, struct ast_chann
321 + if (clframe->lock_frame->owner == oldchan) {
322 + clframe->lock_frame->owner = newchan;
323 + }
324 +- /* We don't move requesters, because the thread stack is different */
325 + clframe->channel = newchan;
326 + }
327 + AST_LIST_UNLOCK(list);
328 + }
329 +
330 +-static void *lock_broker(void *unused)
331 +-{
332 +- struct lock_frame *frame;
333 +- struct timespec forever = { 1000000, 0 };
334 +- for (;;) {
335 +- int found_requester = 0;
336 +-
337 +- /* Test for cancel outside of the lock */
338 +- pthread_testcancel();
339 +- AST_LIST_LOCK(&locklist);
340 +-
341 +- AST_LIST_TRAVERSE(&locklist, frame, entries) {
342 +- if (ao2_container_count(frame->requesters)) {
343 +- found_requester++;
344 +- ast_mutex_lock(&frame->mutex);
345 +- if (!frame->owner) {
346 +- ast_cond_signal(&frame->cond);
347 +- }
348 +- ast_mutex_unlock(&frame->mutex);
349 +- }
350 +- }
351 +-
352 +- AST_LIST_UNLOCK(&locklist);
353 +- pthread_testcancel();
354 +-
355 +- /* If there are no requesters, then wait for a signal */
356 +- if (!found_requester) {
357 +- nanosleep(&forever, NULL);
358 +- } else {
359 +- sched_yield();
360 +- }
361 +- }
362 +- /* Not reached */
363 +- return NULL;
364 +-}
365 +-
366 +-static int ast_channel_cmp_cb(void *obj, void *arg, int flags)
367 +-{
368 +- struct ast_channel *chan = obj, *cmp_args = arg;
369 +- return strcasecmp(ast_channel_name(chan), ast_channel_name(cmp_args)) ? 0 : CMP_MATCH;
370 +-}
371 +-
372 + static int get_lock(struct ast_channel *chan, char *lockname, int trylock)
373 + {
374 + struct ast_datastore *lock_store = ast_channel_datastore_find(chan, &lock_info, NULL);
375 +@@ -290,17 +249,13 @@ static int get_lock(struct ast_channel *chan, char *lockname, int trylock)
376 + AST_LIST_UNLOCK(&locklist);
377 + return -1;
378 + }
379 +- current->requesters = ao2_container_alloc_list(AO2_ALLOC_OPT_LOCK_MUTEX, 0,
380 +- NULL, ast_channel_cmp_cb);
381 +- if (!current->requesters) {
382 +- ast_mutex_destroy(&current->mutex);
383 +- ast_cond_destroy(&current->cond);
384 +- ast_free(current);
385 +- AST_LIST_UNLOCK(&locklist);
386 +- return -1;
387 +- }
388 ++ current->requesters = 0;
389 + AST_LIST_INSERT_TAIL(&locklist, current, entries);
390 + }
391 ++ /* Add to requester list */
392 ++ ast_mutex_lock(&current->mutex);
393 ++ current->requesters++;
394 ++ ast_mutex_unlock(&current->mutex);
395 + AST_LIST_UNLOCK(&locklist);
396 +
397 + /* Found lock or created one - now find or create the corresponding link in the channel */
398 +@@ -337,44 +292,42 @@ static int get_lock(struct ast_channel *chan, char *lockname, int trylock)
399 + * the same amount, before we'll release this one.
400 + */
401 + if (current->owner == chan) {
402 ++ /* We're not a requester, we already have it */
403 ++ ast_mutex_lock(&current->mutex);
404 ++ current->requesters--;
405 ++ ast_mutex_unlock(&current->mutex);
406 + current->count++;
407 + return 0;
408 + }
409 +
410 +- /* Okay, we have both frames, so now we need to try to lock.
411 +- *
412 +- * Locking order: always lock locklist first. We need the
413 +- * locklist lock because the broker thread counts whether
414 +- * there are requesters with the locklist lock held, and we
415 +- * need to hold it, so that when we send our signal, below,
416 +- * to wake up the broker thread, it definitely will see that
417 +- * a requester exists at that point in time. Otherwise, we
418 +- * could add to the requesters after it has already seen that
419 +- * that lock is unoccupied and wait forever for another signal.
420 +- */
421 +- AST_LIST_LOCK(&locklist);
422 +- ast_mutex_lock(&current->mutex);
423 +- /* Add to requester list */
424 +- ao2_link(current->requesters, chan);
425 +- pthread_kill(broker_tid, SIGURG);
426 +- AST_LIST_UNLOCK(&locklist);
427 +-
428 + /* Wait up to three seconds from now for LOCK. */
429 + now = ast_tvnow();
430 + timeout.tv_sec = now.tv_sec + 3;
431 + timeout.tv_nsec = now.tv_usec * 1000;
432 +
433 +- if (!current->owner
434 +- || (!trylock
435 +- && !(res = ast_cond_timedwait(&current->cond, &current->mutex, &timeout)))) {
436 +- res = 0;
437 ++ ast_mutex_lock(&current->mutex);
438 ++
439 ++ res = 0;
440 ++ while (!trylock && !res && current->owner) {
441 ++ res = ast_cond_timedwait(&current->cond, &current->mutex, &timeout);
442 ++ }
443 ++ if (current->owner) {
444 ++ /* timeout;
445 ++ * trylock; or
446 ++ * cond_timedwait failed.
447 ++ *
448 ++ * either way, we fail to obtain the lock.
449 ++ */
450 ++ res = -1;
451 ++ } else {
452 + current->owner = chan;
453 + current->count++;
454 +- } else {
455 +- res = -1;
456 ++ res = 0;
457 + }
458 + /* Remove from requester list */
459 +- ao2_unlink(current->requesters, chan);
460 ++ current->requesters--;
461 ++ if (res && unloading)
462 ++ ast_cond_signal(&current->cond);
463 + ast_mutex_unlock(&current->mutex);
464 +
465 + return res;
466 +@@ -422,7 +375,10 @@ static int unlock_read(struct ast_channel *chan, const char *cmd, char *data, ch
467 + }
468 +
469 + if (--clframe->lock_frame->count == 0) {
470 ++ ast_mutex_lock(&clframe->lock_frame->mutex);
471 + clframe->lock_frame->owner = NULL;
472 ++ ast_cond_signal(&clframe->lock_frame->cond);
473 ++ ast_mutex_unlock(&clframe->lock_frame->mutex);
474 + }
475 +
476 + ast_copy_string(buf, "1", len);
477 +@@ -478,34 +434,34 @@ static int unload_module(void)
478 + /* Module flag */
479 + unloading = 1;
480 +
481 ++ /* Make it impossible for new requesters to be added
482 ++ * NOTE: channels could already be in get_lock() */
483 ++ ast_custom_function_unregister(&lock_function);
484 ++ ast_custom_function_unregister(&trylock_function);
485 ++
486 + AST_LIST_LOCK(&locklist);
487 +- while ((current = AST_LIST_REMOVE_HEAD(&locklist, entries))) {
488 +- /* If any locks are currently in use, then we cannot unload this module */
489 +- if (current->owner || ao2_container_count(current->requesters)) {
490 +- /* Put it back */
491 +- AST_LIST_INSERT_HEAD(&locklist, current, entries);
492 +- AST_LIST_UNLOCK(&locklist);
493 +- unloading = 0;
494 +- return -1;
495 ++ AST_LIST_TRAVERSE(&locklist, current, entries) {
496 ++ ast_mutex_lock(&current->mutex);
497 ++ while (current->owner || current->requesters) {
498 ++ /* either the mutex is locked, or other parties are currently in get_lock,
499 ++ * we need to wait for all of those to clear first */
500 ++ ast_cond_wait(&current->cond, &current->mutex);
501 + }
502 ++ ast_mutex_unlock(&current->mutex);
503 ++ /* At this point we know:
504 ++ * 1. the lock has been released,
505 ++ * 2. there are no requesters (nor should any be able to sneak in).
506 ++ */
507 + ast_mutex_destroy(&current->mutex);
508 +- ao2_ref(current->requesters, -1);
509 ++ ast_cond_destroy(&current->cond);
510 + ast_free(current);
511 + }
512 ++ AST_LIST_UNLOCK(&locklist);
513 ++ AST_LIST_HEAD_DESTROY(&locklist);
514 +
515 +- /* No locks left, unregister functions */
516 +- ast_custom_function_unregister(&lock_function);
517 +- ast_custom_function_unregister(&trylock_function);
518 ++ /* At this point we can safely stop access to UNLOCK */
519 + ast_custom_function_unregister(&unlock_function);
520 +
521 +- if (broker_tid != AST_PTHREADT_NULL) {
522 +- pthread_cancel(broker_tid);
523 +- pthread_kill(broker_tid, SIGURG);
524 +- pthread_join(broker_tid, NULL);
525 +- }
526 +-
527 +- AST_LIST_UNLOCK(&locklist);
528 +-
529 + return 0;
530 + }
531 +
532 +@@ -515,13 +471,6 @@ static int load_module(void)
533 + res |= ast_custom_function_register_escalating(&trylock_function, AST_CFE_READ);
534 + res |= ast_custom_function_register_escalating(&unlock_function, AST_CFE_READ);
535 +
536 +- if (ast_pthread_create_background(&broker_tid, NULL, lock_broker, NULL)) {
537 +- ast_log(LOG_ERROR, "Failed to start lock broker thread. Unloading func_lock module.\n");
538 +- broker_tid = AST_PTHREADT_NULL;
539 +- unload_module();
540 +- return AST_MODULE_LOAD_DECLINE;
541 +- }
542 +-
543 + return res;
544 + }
545 +
546 +--
547 +2.26.2
548 +
549
550 diff --git a/net-misc/asterisk/files/asterisk-16.14.0-autoconf-lua-version.patch b/net-misc/asterisk/files/asterisk-16.14.0-autoconf-lua-version.patch
551 deleted file mode 100644
552 index 6e4c8237e66..00000000000
553 --- a/net-misc/asterisk/files/asterisk-16.14.0-autoconf-lua-version.patch
554 +++ /dev/null
555 @@ -1,31 +0,0 @@
556 ---- a/configure.ac
557 -+++ b/configure.ac
558 -@@ -2553,20 +2553,15 @@
559 - fi
560 - AST_EXT_LIB_CHECK([OPUSFILE], [opusfile], [op_open_callbacks], [opus/opusfile.h], [], [$__opus_include])
561 -
562 --for ver in 5.3 5.2 5.1; do
563 -- AST_EXT_LIB_CHECK([LUA], lua${ver}, [luaL_newstate], lua${ver}/lua.h, [-lm])
564 -- if test "x${PBX_LUA}" = "x1" ; then
565 -- if test x"${LUA_DIR}" = x; then
566 -- LUA_INCLUDE="${LUA_INCLUDE} -I/usr/include/lua${ver}"
567 -- else
568 -- LUA_INCLUDE="${LUA_INCLUDE} -I${LUA_DIR}/lua${ver}"
569 -- fi
570 -- break;
571 -+AST_EXT_LIB_CHECK([LUA], ${LUA_IMPL}, [luaL_newstate], ${LUA_IMPL}/lua.h, [-lm])
572 -+if test "x${PBX_LUA}" = "x1" ; then
573 -+ if test x"${LUA_DIR}" = x; then
574 -+ LUA_INCLUDE="${LUA_INCLUDE} -I/usr/include/${LUA_IMPL}"
575 -+ else
576 -+ LUA_INCLUDE="${LUA_INCLUDE} -I${LUA_DIR}/${LUA_IMPL}"
577 - fi
578 --done
579 --
580 --# Some distributions (like openSUSE and NetBSD) remove the 5.x suffix.
581 --AST_EXT_LIB_CHECK([LUA], [lua], [luaL_newstate], [lua.h], [-lm])
582 -+ break;
583 -+fi
584 -
585 - # Accept either RADIUS client library, their APIs are fully compatible,
586 - # just different header filenames and different SONAMEs
587
588 diff --git a/profiles/package.mask b/profiles/package.mask
589 index 7c9658bed3c..e361d0dbb9e 100644
590 --- a/profiles/package.mask
591 +++ b/profiles/package.mask
592 @@ -519,7 +519,8 @@ kde-apps/kdebase-meta:5
593 >=net-irc/hexchat-2.14.3-r100
594 >=net-irc/weechat-3.0-r100
595 >=net-libs/axtls-2.1.5-r100
596 -=net-misc/asterisk-16.14.0-r100
597 +=net-misc/asterisk-13.38.1-r1
598 +=net-misc/asterisk-16.15.1-r1
599 >=net-mail/dovecot-2.3.11.3-r100
600 >=net-p2p/eiskaltdcpp-2.2.10-r100
601 >=sci-astronomy/celestia-1.7.0_pre20200316-r100