[BACK]Return to patch-main_taskprocessor.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / pkgsrc / comms / asterisk16 / patches

File: [cvs.NetBSD.org] / pkgsrc / comms / asterisk16 / patches / patch-main_taskprocessor.c (download)

Revision 1.1, Thu Feb 11 11:54:13 2021 UTC (8 months, 1 week ago) by ryoon
Branch: MAIN
CVS Tags: pkgsrc-2021Q3-base, pkgsrc-2021Q3, pkgsrc-2021Q2-base, pkgsrc-2021Q2, pkgsrc-2021Q1-base, pkgsrc-2021Q1, HEAD

asterisk16: Add forgotten patches

$NetBSD: patch-main_taskprocessor.c,v 1.1 2021/02/11 11:54:13 ryoon Exp $

* Fix segfault under NetBSD/aarch64 9.99.80.

--- main/taskprocessor.c.orig	2021-01-21 16:28:04.000000000 +0000
+++ main/taskprocessor.c
@@ -37,6 +37,13 @@
 #include "asterisk/taskprocessor.h"
 #include "asterisk/sem.h"
 
+/* XXX, pthread_equal() is misused to compare non-valid thread pointers */
+static int
+pt_pthread_equal(pthread_t t1, pthread_t t2)
+{
+	return t1 == t2;
+}
+
 /*!
  * \brief tps_task structure is queued to a taskprocessor
  *
@@ -263,7 +270,7 @@ static void default_listener_shutdown(st
 
 	ast_assert(pvt->poll_thread != AST_PTHREADT_NULL);
 
-	if (pthread_equal(pthread_self(), pvt->poll_thread)) {
+	if (pt_pthread_equal(pthread_self(), pvt->poll_thread)) {
 		res = pthread_detach(pvt->poll_thread);
 		if (res != 0) {
 			ast_log(LOG_ERROR, "pthread_detach(): %s\n", strerror(errno));
@@ -1268,7 +1275,7 @@ int ast_taskprocessor_is_task(struct ast
 	int is_task;
 
 	ao2_lock(tps);
-	is_task = pthread_equal(tps->thread, pthread_self());
+	is_task = pt_pthread_equal(tps->thread, pthread_self());
 	ao2_unlock(tps);
 	return is_task;
 }