Changes in / [83724d9:7bdf6d1]


Ignore:
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • configure.in

    r0e8f8cb r62ee4ec  
    212212
    213213AC_CHECK_LIB(crypto, EVP_EncryptInit_ex, cryptofound=1, cryptofound=0)
     214if test "$cryptofound" = 1; then
     215        AC_CHECK_HEADER(openssl/evp.h, cryptofound=1, cryptofound=0)
     216fi
    214217
    215218# Check for libpcap
     
    694697reportopt "Building man pages/documentation" $libtrace_doxygen
    695698reportopt "Building tracetop (requires libncurses)" $with_ncurses
    696 reportopt "Building traceanon with CryptoPan (requires libcrypto)" $have_crypto
     699reportopt "Building traceanon with CryptoPan (requires libcrypto and openssl/evp.h)" $have_crypto
    697700
    698701# Report any errors relating to missing bison, flex, etc.
  • lib/format_ndag.c

    r3004d6c r7c33187  
    114114        uint64_t received_packets;
    115115
    116         fd_set allsocks;
    117116        int maxfd;
    118117} recvstream_t;
     
    488487                FORMAT_DATA->receivers[i].received_packets = 0;
    489488                FORMAT_DATA->receivers[i].missing_records = 0;
    490                 FD_ZERO(&(FORMAT_DATA->receivers[i].allsocks));
    491489                FORMAT_DATA->receivers[i].maxfd = -1;
    492490
     
    771769        ssock->recordcount = 0;
    772770        rt->sourcecount += 1;
    773         FD_SET(ssock->sock, &(rt->allsocks));
    774771        if (ssock->sock > rt->maxfd) {
    775772                rt->maxfd = ssock->sock;
     
    881878                fprintf(stderr, "Received invalid record on the channel for %s:%u.\n",
    882879                                ssock->groupaddr, ssock->port);
    883                 FD_CLR(ssock->sock, &(rt->allsocks));
    884880                close(ssock->sock);
    885881                ssock->sock = -1;
     
    943939#if HAVE_RECVMMSG
    944940        int i;
    945 #endif
    946 
    947         if (ssock->sock == -1) {
    948                 return 0;
    949         }
    950 
    951 #if HAVE_RECVMMSG
    952         /* Plenty of full buffers, just use the packets in those */
    953         if (ssock->bufavail < RECV_BATCH_SIZE / 2) {
    954                 return 1;
    955         }
    956 #else
    957         if (ssock->bufavail == 0) {
    958                 return 1;
    959         }
    960941#endif
    961942
     
    987968                                        ssock->port);
    988969
    989                                 FD_CLR(ssock->sock, &(rt->allsocks));
    990970                                close(ssock->sock);
    991971                                ssock->sock = -1;
     
    997977                                ssock->groupaddr, ssock->port,
    998978                                strerror(errno));
    999                         FD_CLR(ssock->sock, &(rt->allsocks));
    1000979                        close(ssock->sock);
    1001980                        ssock->sock = -1;
     
    10351014        struct timeval tv;
    10361015        fd_set fds;
     1016        int maxfd = 0;
    10371017        struct timeval zerotv;
    10381018
     
    10401020        gottime = 0;
    10411021
    1042         fds = rt->allsocks;
     1022        FD_ZERO(&fds);
    10431023
    10441024        if (rt->maxfd == -1) {
     
    10491029        zerotv.tv_usec = 0;
    10501030
    1051         if (select(rt->maxfd + 1, &fds, NULL, NULL, &zerotv) == -1) {
     1031        for (i = 0; i < rt->sourcecount; i++) {
     1032                if (rt->sources[i].sock == -1) {
     1033                        continue;
     1034                }
     1035
     1036#if HAVE_RECVMMSG
     1037                /* Plenty of full buffers, just use the packets in those */
     1038                if (rt->sources[i].bufavail < RECV_BATCH_SIZE / 2) {
     1039                        readybufs ++;
     1040                        continue;
     1041                }
     1042#else
     1043                if (rt->sources[i].bufavail == 0) {
     1044                        readybufs ++;
     1045                        continue;
     1046                }
     1047#endif
     1048                FD_SET(rt->sources[i].sock, &fds);
     1049                if (maxfd < rt->sources[i].sock) {
     1050                        maxfd = rt->sources[i].sock;
     1051                }
     1052        }
     1053
     1054
     1055        if (maxfd <= 0) {
     1056                return readybufs;
     1057        }
     1058
     1059        if (select(maxfd + 1, &fds, NULL, NULL, &zerotv) == -1) {
    10521060                /* log the error? XXX */
    10531061                return -1;
     
    10561064        for (i = 0; i < rt->sourcecount; i++) {
    10571065                if (!FD_ISSET(rt->sources[i].sock, &fds)) {
     1066                        if (rt->sources[i].bufavail < ENCAP_BUFFERS) {
     1067                                readybufs ++;
     1068                        }
    10581069                        continue;
    10591070                }
  • lib/libtrace.h.in

    r29cafc0 rc1205bd  
    560560        uint64_t internalid;            /** Internal identifier for the pkt */
    561561        void *srcbucket;
     562
     563        pthread_mutex_t ref_lock;       /**< Lock for reference counter */
     564        int refcount;                 /**< Reference counter */
     565
    562566} libtrace_packet_t;
    563567
     
    17751779DLLEXPORT void trace_destroy_packet(libtrace_packet_t *packet);
    17761780
    1777 
    17781781/** Read the next packet from an input trace
    17791782 *
  • lib/libtrace_parallel.h

    r5c07bfe rc1205bd  
    12721272DLLEXPORT void trace_free_packet(libtrace_t * libtrace, libtrace_packet_t * packet);
    12731273
     1274/** Increments the internal reference counter for a packet.
     1275 * @param packet        The packet opaque pointer
     1276 *
     1277 * You may wish to use this function (and its decrementing counterpart)
     1278 * in situations where you are retaining multiple references to a packet
     1279 * outside of the core packet processing function. This will ensure that
     1280 * the packet is not released until there are no more outstanding references
     1281 * to the packet anywhere in your program.
     1282 */
     1283DLLEXPORT void trace_increment_packet_refcount(libtrace_packet_t *packet);
     1284
     1285/** Decrements the internal reference counter for a packet.
     1286 * @param packet        The packet opaque pointer
     1287 *
     1288 * If the reference counter goes below one, trace_fin_packet() will be
     1289 * called on the packet.
     1290 *
     1291 * You may wish to use this function (and its incrementing counterpart)
     1292 * in situations where you are retaining multiple references to a packet
     1293 * outside of the core packet processing function. This will ensure that
     1294 * the packet is not released until there are no more outstanding references
     1295 * to the packet anywhere in your program.
     1296 */
     1297DLLEXPORT void trace_decrement_packet_refcount(libtrace_packet_t *packet);
     1298
     1299
    12741300/** Provides some basic information about a trace based on its input format.
    12751301 *
  • lib/trace.c

    re375e0f rc1205bd  
    805805
    806806        packet->buf_control=TRACE_CTRL_PACKET;
     807        pthread_mutex_init(&(packet->ref_lock), NULL);
    807808        trace_clear_cache(packet);
    808809        return packet;
     
    856857                free(packet->buffer);
    857858        }
     859        pthread_mutex_destroy(&(packet->ref_lock));
    858860        packet->buf_control=(buf_control_t)'\0';
    859861                                /* A "bad" value to force an assert
     
    23162318        packet->l3_remaining = 0;
    23172319        packet->l4_remaining = 0;
     2320        packet->refcount = 0;
    23182321
    23192322}
  • lib/trace_parallel.c

    r83724d9 r83724d9  
    26022602}
    26032603
     2604DLLEXPORT void trace_increment_packet_refcount(libtrace_packet_t *packet) {
     2605        pthread_mutex_lock(&(packet->ref_lock));
     2606        if (packet->refcount < 0) {
     2607                packet->refcount = 1;
     2608        } else {
     2609                packet->refcount ++;
     2610        }
     2611        pthread_mutex_unlock(&(packet->ref_lock));
     2612}
     2613
     2614DLLEXPORT void trace_decrement_packet_refcount(libtrace_packet_t *packet) {
     2615        pthread_mutex_lock(&(packet->ref_lock));
     2616        packet->refcount --;
     2617
     2618        if (packet->refcount <= 0) {
     2619                trace_free_packet(packet->trace, packet);
     2620        }
     2621        pthread_mutex_unlock(&(packet->ref_lock));
     2622}
     2623
     2624
    26042625DLLEXPORT libtrace_info_t *trace_get_information(libtrace_t * libtrace) {
    26052626        if (libtrace->format)
Note: See TracChangeset for help on using the changeset viewer.