]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-10167 track joins and only do them once
authorAnthony Minessale <anthm@freeswitch.org>
Mon, 27 Mar 2017 18:06:43 +0000 (13:06 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Mon, 27 Mar 2017 18:06:43 +0000 (13:06 -0500)
libs/libks/src/include/ks_threadmutex.h
libs/libks/src/include/ks_types.h
libs/libks/src/ks_thread.c

index fea61842003dd6cea9e48218d43a01656d8ad5a2..1be750eb3702a36cfa0c32afafaebae51752a1e5 100644 (file)
@@ -78,6 +78,7 @@ struct ks_thread {
            ks_thread_state_t state;
                uint8_t priority;
                void *return_data;
+       uint8_t joined;
        };
 
        typedef enum {
index e50dc5aa21c5d70212b45d9ec762d32ddee9a4de..201ea3f7f643c44a03b1b701616df47a28eafc3d 100644 (file)
@@ -89,6 +89,7 @@ KS_BEGIN_EXTERN_C
                KS_STATUS_GENERR,
                KS_STATUS_INACTIVE,
                KS_STATUS_TIMEOUT,
+               KS_STATUS_DUPLICATE_OPERATION,
                /* Memory pool errors */
                KS_STATUS_REFS_EXIST,      /* references exist */
                KS_STATUS_ARG_NULL,        /* function argument is null */
index 25b08184a6c51ab30768caf7bbd1b0d2ef9501ea..92c608bd279daf29e1c7c07e3ab4fc6ad73ca586 100644 (file)
@@ -197,12 +197,20 @@ KS_DECLARE(uint8_t) ks_thread_priority(ks_thread_t *thread) {
 }
 
 KS_DECLARE(ks_status_t) ks_thread_join(ks_thread_t *thread) {
+
+       if (thread->joined) {
+               return KS_STATUS_DUPLICATE_OPERATION;
+       }
+
 #ifdef WIN32
        WaitForSingleObject(thread->handle, INFINITE);
 #else
        void *ret;
        pthread_join(thread->handle, &ret);
 #endif
+
+       thread->joined++;
+
        return KS_STATUS_SUCCESS;
 }