Changeset c1205bd
- Timestamp:
- 03/09/18 16:46:26 (3 years ago)
- Branches:
- cachetimestamps, develop, etsilive, master, rc-4.0.4, ringdecrementfix, ringperformance
- Children:
- 7c33187
- Parents:
- 62ee4ec
- Location:
- lib
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/libtrace.h.in
r29cafc0 rc1205bd 560 560 uint64_t internalid; /** Internal identifier for the pkt */ 561 561 void *srcbucket; 562 563 pthread_mutex_t ref_lock; /**< Lock for reference counter */ 564 int refcount; /**< Reference counter */ 565 562 566 } libtrace_packet_t; 563 567 … … 1775 1779 DLLEXPORT void trace_destroy_packet(libtrace_packet_t *packet); 1776 1780 1777 1778 1781 /** Read the next packet from an input trace 1779 1782 * -
lib/libtrace_parallel.h
r5c07bfe rc1205bd 1272 1272 DLLEXPORT void trace_free_packet(libtrace_t * libtrace, libtrace_packet_t * packet); 1273 1273 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 */ 1283 DLLEXPORT 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 */ 1297 DLLEXPORT void trace_decrement_packet_refcount(libtrace_packet_t *packet); 1298 1299 1274 1300 /** Provides some basic information about a trace based on its input format. 1275 1301 * -
lib/trace.c
re375e0f rc1205bd 805 805 806 806 packet->buf_control=TRACE_CTRL_PACKET; 807 pthread_mutex_init(&(packet->ref_lock), NULL); 807 808 trace_clear_cache(packet); 808 809 return packet; … … 856 857 free(packet->buffer); 857 858 } 859 pthread_mutex_destroy(&(packet->ref_lock)); 858 860 packet->buf_control=(buf_control_t)'\0'; 859 861 /* A "bad" value to force an assert … … 2316 2318 packet->l3_remaining = 0; 2317 2319 packet->l4_remaining = 0; 2320 packet->refcount = 0; 2318 2321 2319 2322 } -
lib/trace_parallel.c
re375e0f rc1205bd 2601 2601 } 2602 2602 2603 DLLEXPORT void trace_increment_packet_refcount(libtrace_packet_t *packet) { 2604 pthread_mutex_lock(&(packet->ref_lock)); 2605 if (packet->refcount < 0) { 2606 packet->refcount = 1; 2607 } else { 2608 packet->refcount ++; 2609 } 2610 pthread_mutex_unlock(&(packet->ref_lock)); 2611 } 2612 2613 DLLEXPORT void trace_decrement_packet_refcount(libtrace_packet_t *packet) { 2614 pthread_mutex_lock(&(packet->ref_lock)); 2615 packet->refcount --; 2616 2617 if (packet->refcount <= 0) { 2618 trace_free_packet(packet->trace, packet); 2619 } 2620 pthread_mutex_unlock(&(packet->ref_lock)); 2621 } 2622 2623 2603 2624 DLLEXPORT libtrace_info_t *trace_get_information(libtrace_t * libtrace) { 2604 2625 if (libtrace->format)
Note: See TracChangeset
for help on using the changeset viewer.