Ignore:
Timestamp:
11/27/14 14:19:19 (8 years ago)
Author:
Richard Sanger <rsangerarj@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
d7fd648
Parents:
21f5f0f
Message:

Fixes bug where packets could be destroyed by unregistered threads
We now destroy the packet object cache thread caches before unresistering a thread

Also includes some whitespace fixes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/data-struct/object_cache.c

    r78911b5 r6e41e73  
    1 
    21#include "object_cache.h"
    32#include <assert.h>
     
    3433
    3534/**
    36  * @brief free_array assumes we DONT hold spin
     35 * @brief unregister_thread assumes we DONT hold spin
    3736 */
    3837static inline void unregister_thread(struct local_cache *lc) {
     
    7170
    7271/**
    73  * @brief free_array assumes we hold spin!!!
     72 * @brief register_thread assumes we DONT hold spin
    7473 */
    7574static inline void register_thread(libtrace_ocache_t *oc, struct local_cache *lc) {
     
    429428}
    430429
     430/**
     431 * @brief ocache_unregister_thread removes a thread from an ocache.
     432 * @param The ocache to remove this thread, this will free any packets in the TLS cache
     433 */
     434DLLEXPORT void libtrace_ocache_unregister_thread(libtrace_ocache_t *oc) {
     435        size_t i;
     436        struct local_cache *lc = find_cache(oc);
     437
     438        if (lc) {
     439                for (i = 0; i < t_mem_caches_used; ++i) {
     440                        if (&t_mem_caches[i] == lc) {
     441                                // Free the cache against the ocache
     442                                unregister_thread(&t_mem_caches[i]);
     443                                free(t_mem_caches[i].cache);
     444                                // And remove it from the thread itself
     445                                --t_mem_caches_used;
     446                                t_mem_caches[i] = t_mem_caches[t_mem_caches_used];
     447                                memset(&t_mem_caches[t_mem_caches_used], 0, sizeof(struct local_cache));
     448                        }
     449                }
     450        }
     451}
Note: See TracChangeset for help on using the changeset viewer.