Ignore:
Timestamp:
10/14/15 15:24:10 (6 years ago)
Author:
Shane Alcock <salcock@…>
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:
b24d186, f0cb0d4, f72e13d
Parents:
44f9892
Message:

Fix memory leak with heavily filtered RT inputs

Bucket buffers that contained entirely filtered packets were never
being freed if they weren't at the front of our bucket list, which would
chew through memory very quickly as soon as we had a non-empty bucket at
the front of the list but not enough packets to result in a batch being
spread amongst the processing threads.

File:
1 edited

Legend:

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

    r348396b r21c0d70  
    5252DLLEXPORT void libtrace_create_new_bucket(libtrace_bucket_t *b, void *buffer) {
    5353
     54        libtrace_bucket_node_t tmp;
    5455        libtrace_bucket_node_t *bnode = (libtrace_bucket_node_t *)malloc(
    5556                        sizeof(libtrace_bucket_node_t));
     57
     58        /* If the last node was never used, i.e. all packets within that node
     59         * buffer were filtered, we need to make sure we free the buffer
     60         * before we lose track of it.
     61         */
     62        pthread_mutex_lock(&b->lock);
     63        if (b->node && b->node->startindex == 0) {
     64                clear_bucket_node(b->node);
     65                libtrace_list_pop_back(b->nodelist, &tmp);
     66                free(b->node);
     67        }
     68        pthread_mutex_unlock(&b->lock);
     69
    5670
    5771        bnode->startindex = 0;
     
    159173        assert(s < bnode->slots);
    160174        assert(bnode->released[s] != 0);
    161        
     175
    162176
    163177        if (bnode->released[s] == 1) {
     
    170184                        b->nextid = previd;
    171185                        bnode->released[s] = 0;
     186                        if (id == bnode->startindex)
     187                                bnode->startindex = 0;
    172188                } else {
    173189                        bnode->released[s] = 2;
Note: See TracChangeset for help on using the changeset viewer.