Changeset 63af502
- Timestamp:
- 09/05/14 16:17:32 (6 years ago)
- 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:
- cf686e1
- Parents:
- a7c8f4a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/format_linux.c
rc70f59f r63af502 893 893 int snaplen; 894 894 uint32_t flags = 0; 895 fd_set readfds; 896 struct timeval tout; 897 int ret; 895 898 896 899 if (!packet->buffer || packet->buf_control == TRACE_CTRL_EXTERNAL) { … … 928 931 iovec.iov_len = snaplen; 929 932 930 hdr->wirelen = recvmsg(FORMAT(libtrace->format_data)->fd, &msghdr, MSG_TRUNC); 933 /* Use select to allow us to time out occasionally to check if someone 934 * has hit Ctrl-C or otherwise wants us to stop reading and return 935 * so they can exit their program. 936 */ 937 938 while (1) { 939 tout.tv_sec = 0; 940 tout.tv_usec = 500000; 941 FD_ZERO(&readfds); 942 FD_SET(FORMAT(libtrace->format_data)->fd, &readfds); 943 944 ret = select(FORMAT(libtrace->format_data)->fd + 1, &readfds, 945 NULL, NULL, &tout); 946 if (ret < 0 && errno != EINTR) { 947 trace_set_err(libtrace, errno, "select"); 948 return -1; 949 } else if (ret < 0) { 950 continue; 951 } 952 953 if (FD_ISSET(FORMAT(libtrace->format_data)->fd, &readfds)) { 954 /* There's something available for us to read */ 955 break; 956 } 957 958 959 /* If we get here, we timed out -- check if we should halt */ 960 if (libtrace_halt) 961 return 0; 962 } 963 964 hdr->wirelen = recvmsg(FORMAT(libtrace->format_data)->fd, &msghdr, MSG_TRUNC); 931 965 932 966 if (hdr->wirelen==~0U) { … … 1044 1078 assert((((unsigned long) header) & (pagesize - 1)) == 0); 1045 1079 1046 /* TP_STATUS_USER means that we can use the frame. 1047 * When a slot does not have this flag set, the frame is not 1048 * ready for consumption. 1049 */ 1050 while (!(header->tp_status & TP_STATUS_USER)) { 1080 while (1) { 1051 1081 pollset.fd = FORMAT(libtrace->format_data)->fd; 1052 1082 pollset.events = POLLIN; 1053 1083 pollset.revents = 0; 1054 1084 /* Wait for more data */ 1055 ret = poll(&pollset, 1, -1);1085 ret = poll(&pollset, 1, 500); 1056 1086 if (ret < 0) { 1057 1087 if (errno != EINTR) 1058 1088 trace_set_err(libtrace,errno,"poll()"); 1059 1089 return -1; 1060 } 1090 } else if (ret == 0) { 1091 /* Poll timed out - check if we should exit */ 1092 if (libtrace_halt) 1093 return 0; 1094 continue; 1095 } 1096 1097 /* TP_STATUS_USER means that we can use the frame. 1098 * When a slot does not have this flag set, the frame is not 1099 * ready for consumption. 1100 */ 1101 if (header->tp_status & TP_STATUS_USER) 1102 break; 1061 1103 } 1062 1104
Note: See TracChangeset
for help on using the changeset viewer.