From d7e568e5908711a351d926c026537d3d389f8f9b Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Mon, 11 May 2015 03:32:52 +0000
Subject: [PATCH] Added msgQueueOwner(), returns TRUE if called from the
 queue's owning thread.

---
 src/xpdev/msg_queue.c | 12 ++++++++++--
 src/xpdev/msg_queue.h |  3 ++-
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/xpdev/msg_queue.c b/src/xpdev/msg_queue.c
index 35b1efb4fd..87ce76d2e2 100644
--- a/src/xpdev/msg_queue.c
+++ b/src/xpdev/msg_queue.c
@@ -8,7 +8,7 @@
  * @format.tab-size 4		(Plain Text/Source Code File Header)			*
  * @format.use-tabs true	(see http://www.synchro.net/ptsc_hdr.html)		*
  *																			*
- * Copyright 2005 Rob Swindell - http://www.synchro.net/copyright.html		*
+ * Copyright Rob Swindell - http://www.synchro.net/copyright.html			*
  *																			*
  * This library is free software; you can redistribute it and/or			*
  * modify it under the terms of the GNU Lesser General Public License		*
@@ -63,6 +63,14 @@ msg_queue_t* DLLCALL msgQueueInit(msg_queue_t* q, long flags)
 	return(q);
 }
 
+BOOL DLLCALL msgQueueOwner(msg_queue_t* q)
+{
+	if(q==NULL)
+		return(FALSE);
+
+	return q->owner_thread_id == pthread_self();
+}
+
 BOOL DLLCALL msgQueueFree(msg_queue_t* q)
 {
 	if(q==NULL)
@@ -204,7 +212,7 @@ void* DLLCALL msgQueuePeek(msg_queue_t* q, long timeout)
 #endif
 		;
 
-	return listNodeData(listFirstNode(list));
+	return  listNodeData(listFirstNode(list));
 }
 
 void* DLLCALL msgQueueFind(msg_queue_t* q, const void* data, size_t length)
diff --git a/src/xpdev/msg_queue.h b/src/xpdev/msg_queue.h
index aa0fa60761..f831edc55d 100644
--- a/src/xpdev/msg_queue.h
+++ b/src/xpdev/msg_queue.h
@@ -8,7 +8,7 @@
  * @format.tab-size 4		(Plain Text/Source Code File Header)			*
  * @format.use-tabs true	(see http://www.synchro.net/ptsc_hdr.html)		*
  *																			*
- * Copyright 2011 Rob Swindell - http://www.synchro.net/copyright.html		*
+ * Copyright Rob Swindell - http://www.synchro.net/copyright.html			*
  *																			*
  * This library is free software; you can redistribute it and/or			*
  * modify it under the terms of the GNU Lesser General Public License		*
@@ -64,6 +64,7 @@ DLLEXPORT BOOL			DLLCALL msgQueueFree(msg_queue_t*);
 
 DLLEXPORT long			DLLCALL msgQueueAttach(msg_queue_t*);
 DLLEXPORT long			DLLCALL msgQueueDetach(msg_queue_t*);
+DLLEXPORT BOOL			DLLCALL msgQueueOwner(msg_queue_t*);
 
 /* Get/Set queue private data */
 DLLEXPORT void*			DLLCALL msgQueueSetPrivateData(msg_queue_t*, void*);
-- 
GitLab