Changeset 4edb310


Ignore:
Timestamp:
01/05/17 13:32:38 (4 years ago)
Author:
Shane Alcock <salcock@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, master, ndag_format, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
2d4e055
Parents:
cff1819 (diff), 47c4490 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'develop' of https://github.com/wanduow/libtrace into develop

Location:
lib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • lib/format_linux_ring.c

    r5e3f16c r47c4490  
    447447#ifdef HAVE_NETPACKET_PACKET_H
    448448#define LIBTRACE_MIN(a,b) ((a)<(b) ? (a) : (b))
     449/* We use TP_STATUS_LIBTRACE to ensure we don't loop back on ourself
     450 * and read the same packet twice if an old packet has not yet been freed */
     451#define TP_STATUS_LIBTRACE 0xFFFFFFFF
     452
    449453inline static int linuxring_read_stream(libtrace_t *libtrace,
    450454                                        libtrace_packet_t *packet,
     
    470474         * ready for consumption.
    471475         */
    472         while (!(header->tp_status & TP_STATUS_USER)) {
     476        while (!(header->tp_status & TP_STATUS_USER) ||
     477               header->tp_status == TP_STATUS_LIBTRACE) {
     478                if ((ret=is_halted(libtrace)) != -1)
     479                        return ret;
    473480                pollset[0].fd = stream->fd;
    474481                pollset[0].events = POLLIN;
     
    509516                        }
    510517                } else {
    511                         /* Poll timed out - check if we should exit */
    512                         if ((ret=is_halted(libtrace)) != -1)
    513                                 return ret;
     518                        /* Poll timed out - check if we should exit on next loop */
    514519                        continue;
    515520                }
     
    518523        packet->buffer = header;
    519524        packet->trace = libtrace;
     525        header->tp_status = TP_STATUS_LIBTRACE;
    520526
    521527        /* If a snaplen was configured, automatically truncate the packet to
     
    574580        /* Fetch the current frame */
    575581        header = GET_CURRENT_BUFFER(FORMAT_DATA_FIRST);
    576         if (header->tp_status & TP_STATUS_USER) {
     582        if (header->tp_status & TP_STATUS_USER &&
     583            header->tp_status != TP_STATUS_LIBTRACE) {
    577584                /* We have a frame waiting */
    578585                event.size = trace_read_packet(libtrace, packet);
  • lib/trace.c

    r5e3f16c radb2c4c  
    550550
    551551        /* Finish the last packet we read - for backwards compatibility */
    552         if (libtrace->last_packet)
     552        if (!libtrace_parallel && libtrace->last_packet)
    553553                trace_fin_packet(libtrace->last_packet);
    554554        assert(libtrace->last_packet == NULL);
     
    697697
    698698        /* Finish any the last packet we read - for backwards compatibility */
    699         if (libtrace->last_packet) {
     699        if (!libtrace_parallel && libtrace->last_packet) {
    700700                trace_fin_packet(libtrace->last_packet);
    701701        }
     
    837837                packet->trace->format->fin_packet(packet);
    838838        }
    839         if (packet->trace && packet->trace->last_packet == packet)
     839        if (!libtrace_parallel && packet->trace &&
     840             packet->trace->last_packet == packet) {
    840841                packet->trace->last_packet = NULL;
     842        }
    841843       
    842844        if (packet->buf_control == TRACE_CTRL_PACKET && packet->buffer) {
     
    868870
    869871                if (packet->trace) {
    870                         pthread_mutex_lock(&packet->trace->libtrace_lock);
    871                         if (packet->trace->last_packet == packet)
    872                                 packet->trace->last_packet = NULL;
    873                         pthread_mutex_unlock(&packet->trace->libtrace_lock);
     872                        if (!libtrace_parallel && packet->trace->last_packet == packet)
     873                                packet->trace->last_packet = NULL;
    874874                }
    875875
     
    960960                        ++libtrace->accepted_packets;
    961961                        ++libtrace->sequence_number;
    962                         if (packet->trace == libtrace)
     962                        if (!libtrace_parallel && packet->trace == libtrace)
    963963                                libtrace->last_packet = packet;
    964964
     
    10031003
    10041004        packet->trace = trace;
    1005         pthread_mutex_lock(&trace->libtrace_lock);
    1006         trace->last_packet = packet;
    1007         pthread_mutex_unlock(&trace->libtrace_lock);
     1005        if (!libtrace_parallel)
     1006                trace->last_packet = packet;
    10081007        /* Clear packet cache */
    10091008        trace_clear_cache(packet);
  • lib/trace_parallel.c

    r5e3f16c r47c4490  
    17331733                if (libtrace->perpkt_thread_count > 1)
    17341734                        libtrace->pread = trace_pread_packet_first_in_first_served;
     1735                        /* Don't wait for a burst of packets if the format is
     1736                         * live as this could block ring based formats and
     1737                         * introduces delay. */
     1738                        if (libtrace->format->info.live) {
     1739                                libtrace->config.burst_size = 1;
     1740                        }
    17351741                else
    17361742                        /* Use standard read_packet */
Note: See TracChangeset for help on using the changeset viewer.