Ignore:
Timestamp:
03/18/15 16:33:17 (6 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:
6b98325
Parents:
1407294
Message:

Reset statistics and first packets on restart

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/trace_parallel.c

    r1407294 r963b13b  
    12741274static int trace_prestart(libtrace_t * libtrace, void *global_blob,
    12751275                          fn_per_pkt per_pkt, fn_reporter reporter) {
    1276         int err = 0;
     1276        int i, err = 0;
    12771277        if (libtrace->state != STATE_PAUSED) {
    12781278                trace_set_err(libtrace, TRACE_ERR_BAD_STATE,
     
    12821282        }
    12831283
     1284        assert(libtrace_parallel);
     1285        assert(!libtrace->perpkt_thread_states[THREAD_RUNNING]);
     1286
     1287        /* Reset first packets */
     1288        pthread_spin_lock(&libtrace->first_packets.lock);
     1289        for (i = 0; i < libtrace->perpkt_thread_count; ++i) {
     1290                assert(!!libtrace->perpkt_threads[i].recorded_first == !!libtrace->first_packets.packets[i].packet);
     1291                if (libtrace->first_packets.packets[i].packet) {
     1292                        trace_destroy_packet(libtrace->first_packets.packets[i].packet);
     1293                        libtrace->first_packets.packets[i].packet = NULL;
     1294                        libtrace->first_packets.packets[i].tv.tv_sec = 0;
     1295                        libtrace->first_packets.packets[i].tv.tv_usec = 0;
     1296                        libtrace->first_packets.count--;
     1297                        libtrace->perpkt_threads[i].recorded_first = false;
     1298                }
     1299        }
     1300        assert(libtrace->first_packets.count == 0);
     1301        libtrace->first_packets.first = 0;
     1302        pthread_spin_unlock(&libtrace->first_packets.lock);
     1303
     1304        /* Reset delay */
     1305        for (i = 0; i < libtrace->perpkt_thread_count; ++i) {
     1306                libtrace->perpkt_threads[i].tracetime_offset_usec = 0;
     1307        }
     1308
     1309        /* Reset statistics */
     1310        for (i = 0; i < libtrace->perpkt_thread_count; ++i) {
     1311                libtrace->perpkt_threads[i].accepted_packets = 0;
     1312                libtrace->perpkt_threads[i].filtered_packets = 0;
     1313        }
     1314        libtrace->accepted_packets = 0;
     1315        libtrace->filtered_packets = 0;
     1316
    12841317        /* Update functions if requested */
    12851318        if (per_pkt)
    12861319                libtrace->per_pkt = per_pkt;
     1320        assert(libtrace->per_pkt);
    12871321        if (reporter)
    12881322                libtrace->reporter = reporter;
    12891323        if(global_blob)
    12901324                libtrace->global_blob = global_blob;
    1291 
    1292         assert(libtrace_parallel);
    1293         assert(!libtrace->perpkt_thread_states[THREAD_RUNNING]);
    1294         assert(libtrace->per_pkt);
    12951325
    12961326        if (libtrace->perpkt_thread_count > 1 &&
Note: See TracChangeset for help on using the changeset viewer.