]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-10167: Temporary commit to test some weirdness with pool freeing and memory mapping
authorShane Bryldt <astaelan@gmail.com>
Fri, 24 Mar 2017 22:05:58 +0000 (16:05 -0600)
committerShane Bryldt <astaelan@gmail.com>
Fri, 24 Mar 2017 22:06:20 +0000 (16:06 -0600)
libs/libks/src/ks_pool.c
libs/libks/src/ks_thread.c
libs/libks/test/testthreadmutex.c

index d9bfc89ee507f2f96a2b745d2ac6154f33a4b869..f501c1924bb72b1efc82ad1112854b0c47245219 100644 (file)
@@ -628,6 +628,10 @@ static int free_pointer(ks_pool_t *mp_p, void *addr, const unsigned long size)
                real_size = size;
        }
 
+       while ((real_size & (sizeof(void *) - 1)) > 0) {
+               real_size++;
+       }
+
        /*
         * We use a specific free bits calculation here because if we are
         * freeing 10 bytes then we will be putting it into the 8-byte free
@@ -1044,7 +1048,7 @@ static int free_mem(ks_pool_t *mp_p, void *addr)
        fence = FENCE_SIZE;
 
        /* now we free the pointer */
-       ret = free_pointer(mp_p, addr, old_size + fence);
+       ret = free_pointer(mp_p, addr, old_size + fence + PREFIX_SIZE);
        if (ret != KS_STATUS_SUCCESS) {
                return ret;
        }
index 02d9fcf33da5ab3ecf48d21bce8d8eb1ee0365d6..cbd778dbb0e449914ccba552369d26f9d0bbdcad 100644 (file)
@@ -93,9 +93,9 @@ static void ks_thread_cleanup(ks_pool_t *mpool, void *ptr, void *arg, int type,
                break;
        case KS_MPCL_DESTROY:
 #ifdef WIN32
-               if (!(thread->flags & KS_THREAD_FLAG_DETATCHED)) {
+               //if (!(thread->flags & KS_THREAD_FLAG_DETATCHED)) {
                        CloseHandle(thread->handle);
-               }
+               //}
 #endif
                break;
        }
@@ -170,7 +170,7 @@ KS_DECLARE(int) ks_thread_set_priority(int nice_val)
 KS_DECLARE(uint8_t) ks_thread_priority(ks_thread_t *thread) {
        uint8_t priority = 0;
 #ifdef WIN32
-       DWORD pri = GetThreadPriority(thread->handle);
+       int pri = GetThreadPriority(thread->handle);
 
        if (pri >= THREAD_PRIORITY_TIME_CRITICAL) {
                priority = 99;
@@ -241,7 +241,7 @@ KS_DECLARE(ks_status_t) ks_thread_create_ex(ks_thread_t **rthread, ks_thread_fun
        }
 
        if (flags & KS_THREAD_FLAG_DETATCHED) {
-               CloseHandle(thread->handle);
+               //CloseHandle(thread->handle);
        }
 
        status = KS_STATUS_SUCCESS;
index ebb593b662dbab4d5029c4b9d497952563a7c856..ce28af07d6443dbc8ddc011bdd7352399847e40c 100644 (file)
@@ -321,12 +321,14 @@ static void test_non_recursive_mutex(void)
 int main(int argc, char **argv)
 {
        ks_init();
-       cpu_count = ks_cpu_count() * 4;
+       //cpu_count = ks_cpu_count() * 4;
+       //cpu_count = ks_cpu_count();
+       cpu_count = 1;
 
        plan(21 + cpu_count * 6);
 
        
-       diag("Starting testing for %d tests\n", 44);
+       diag("Starting testing for %d tests\n", 21 + cpu_count * 6);
 
        create_pool();
        create_mutex();