Changeset 5e3f16c
- Timestamp:
- 12/05/16 19:04:41 (5 years ago)
- 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:
- adb2c4c, cff1819, f8613e4
- Parents:
- 8ccb8536
- Location:
- lib
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/format_bpf.c
ree6e802 r5e3f16c 497 497 498 498 /* Timed out -- check if we should halt */ 499 if ( libtrace_halt)500 return 0;499 if ((ret=is_halted(libtrace)) != -1) 500 return ret; 501 501 } 502 502 -
lib/format_dag25.c
ree6e802 r5e3f16c 1304 1304 return -2; 1305 1305 1306 if ( libtrace_halt)1307 return 0;1306 if ((numbytes=is_halted(libtrace)) != -1) 1307 return numbytes; 1308 1308 /* Block until we see a packet */ 1309 1309 continue; -
lib/format_dpdk.c
rc94f107 r5e3f16c 2107 2107 if (mesg && libtrace_message_queue_count(mesg) > 0) 2108 2108 return READ_MESSAGE; 2109 if ( libtrace_halt)2110 return READ_EOF;2109 if ((nb_rx=is_halted(libtrace)) != -1) 2110 return nb_rx; 2111 2111 /* Wait a while, polling on memory degrades performance 2112 2112 * This relieves the pressure on memory allowing the NIC to DMA */ -
lib/format_linux_int.c
ree6e802 r5e3f16c 215 215 return -1; 216 216 } else { 217 if ( libtrace_halt)218 return READ_EOF;217 if ((ret=is_halted(libtrace)) != -1) 218 return ret; 219 219 } 220 220 } -
lib/format_linux_ring.c
ree6e802 r5e3f16c 510 510 } else { 511 511 /* Poll timed out - check if we should exit */ 512 if ( libtrace_halt)513 return 0;512 if ((ret=is_halted(libtrace)) != -1) 513 return ret; 514 514 continue; 515 515 } -
lib/format_pcap.c
r631fdbc r5e3f16c 447 447 case 1: break; /* no error */ 448 448 case 0: 449 if ( libtrace_halt)450 return 0;449 if ((ret=is_halted(libtrace)) != -1) 450 return ret; 451 451 continue; /* timeout expired */ 452 452 case -1: -
lib/libtrace_int.h
ree6e802 r5e3f16c 327 327 /** Synchronise writes/reads across this format object and attached threads etc */ 328 328 pthread_mutex_t libtrace_lock; 329 /** Packet read lock, seperate from libtrace_lock as to not block while reading a burst */ 330 pthread_mutex_t read_packet_lock; 329 331 /** State */ 330 332 enum trace_state state; … … 606 608 * @return The size of the packet read (in bytes) including the capture 607 609 * framing header, or -1 if an error occurs. 0 is returned in the 608 * event of an EOF .610 * event of an EOF or -2 in the case of interrupting the parallel API. 609 611 * 610 612 * If no packets are available for reading, this function should block … … 1032 1034 */ 1033 1035 extern volatile int libtrace_halt; 1036 1037 /** 1038 * Used by a format to check if trace_interrupt or if a trace_pause/stop has 1039 * been called. Provides backwards compatibility with traditional read 1040 * functions when trace_read_packet() is used by the parallel API. 1041 * 1042 * Returns -1 if not halting otherwise returns the code that the read 1043 * operation should pass on. 1044 */ 1045 static inline int is_halted(libtrace_t *trace) { 1046 if (!(libtrace_halt || trace->state == STATE_PAUSING)) { 1047 return -1; 1048 } else if (libtrace_halt) { 1049 return READ_EOF; 1050 } else { 1051 return READ_MESSAGE; 1052 } 1053 } 1034 1054 1035 1055 /** Registers a new capture format module. -
lib/trace.c
r89e2ff7 r5e3f16c 261 261 /* Parallel inits */ 262 262 ASSERT_RET(pthread_mutex_init(&libtrace->libtrace_lock, NULL), == 0); 263 ASSERT_RET(pthread_mutex_init(&libtrace->read_packet_lock, NULL), == 0); 263 264 ASSERT_RET(pthread_cond_init(&libtrace->perpkt_cond, NULL), == 0); 264 265 libtrace->state = STATE_NEW; … … 385 386 /* Parallel inits */ 386 387 ASSERT_RET(pthread_mutex_init(&libtrace->libtrace_lock, NULL), == 0); 388 ASSERT_RET(pthread_mutex_init(&libtrace->read_packet_lock, NULL), == 0); 387 389 ASSERT_RET(pthread_cond_init(&libtrace->perpkt_cond, NULL), == 0); 388 390 libtrace->state = STATE_NEW; // TODO MAYBE DEAD … … 680 682 681 683 ASSERT_RET(pthread_mutex_destroy(&libtrace->libtrace_lock), == 0); 684 ASSERT_RET(pthread_mutex_destroy(&libtrace->read_packet_lock), == 0); 682 685 ASSERT_RET(pthread_cond_destroy(&libtrace->perpkt_cond), == 0); 683 686 … … 758 761 759 762 ASSERT_RET(pthread_mutex_destroy(&libtrace->libtrace_lock), == 0); 763 ASSERT_RET(pthread_mutex_destroy(&libtrace->read_packet_lock), == 0); 760 764 ASSERT_RET(pthread_cond_destroy(&libtrace->perpkt_cond), == 0); 761 765 … … 921 925 size_t ret; 922 926 int filtret; 923 if ( libtrace_halt)924 return 0;927 if ((ret=is_halted(libtrace)) != (size_t)-1) 928 return ret; 925 929 /* Store the trace we are reading from into the packet opaque 926 930 * structure */ 927 931 packet->trace = libtrace; 928 932 ret=libtrace->format->read_packet(libtrace,packet); 929 if (ret==(size_t)-1 || ret==0) { 933 if (ret==(size_t)READ_MESSAGE || 934 ret==(size_t)-1 || ret==0) { 930 935 packet->trace = NULL; 931 936 return ret; -
lib/trace_parallel.c
r89e2ff7 r5e3f16c 816 816 817 817 if ((packet->error = trace_read_packet(trace, packet)) <1) { 818 break; /* We are EOF or error'd either way we stop */ 818 if (packet->error == READ_MESSAGE) { 819 pkt_skipped = 1; 820 continue; 821 } else { 822 break; /* We are EOF or error'd either way we stop */ 823 } 819 824 } 820 825 … … 884 889 //bool tick_hit = false; 885 890 886 ASSERT_RET(pthread_mutex_lock(&libtrace-> libtrace_lock), == 0);891 ASSERT_RET(pthread_mutex_lock(&libtrace->read_packet_lock), == 0); 887 892 /* Read nb_packets */ 888 893 for (i = 0; i < nb_packets; ++i) { 894 if (libtrace_message_queue_count(&t->messages) > 0) { 895 if ( i==0 ) { 896 ASSERT_RET(pthread_mutex_unlock(&libtrace->read_packet_lock), == 0); 897 return READ_MESSAGE; 898 } else { 899 break; 900 } 901 } 889 902 packets[i]->error = trace_read_packet(libtrace, packets[i]); 890 903 … … 892 905 /* We'll catch this next time if we have already got packets */ 893 906 if ( i==0 ) { 894 ASSERT_RET(pthread_mutex_unlock(&libtrace-> libtrace_lock), == 0);907 ASSERT_RET(pthread_mutex_unlock(&libtrace->read_packet_lock), == 0); 895 908 return packets[i]->error; 896 909 } else { … … 908 921 store_first_packet(libtrace, packets[0], t); 909 922 } 910 ASSERT_RET(pthread_mutex_unlock(&libtrace-> libtrace_lock), == 0);923 ASSERT_RET(pthread_mutex_unlock(&libtrace->read_packet_lock), == 0); 911 924 /* XXX TODO this needs to be inband with packets, or we don't bother in this case 912 925 if (tick_hit) {
Note: See TracChangeset
for help on using the changeset viewer.