- Timestamp:
- 09/04/18 14:56:53 (3 years ago)
- Branches:
- develop, master, ringdecrementfix, ringperformance
- Children:
- 2201d8c
- Parents:
- 37ee856
- Location:
- lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/format_linux_common.c
r47d4f8c rebed638 232 232 close(stream->fd); 233 233 stream->fd = -1; 234 if (stream->rx_ring != MAP_FAILED)235 munmap(stream->rx_ring,236 stream->req.tp_block_size *237 stream->req.tp_block_nr);238 stream->rx_ring = MAP_FAILED;239 stream->rxring_offset = 0;240 234 FORMAT_DATA->dev_stats.if_name[0] = 0; 235 236 /* Don't munmap the rx_ring here -- keep it around as long as 237 * possible to ensure that any packets that the user is still 238 * holding references to remain valid. 239 * 240 * Don't worry, linuxring will munmap the rx_ring as soon as 241 * someone either destroys or restarts the trace. At that point, 242 * any remaining packets from the old ring will be recognisable 243 * as invalid. 244 */ 241 245 } 242 246 -
lib/format_linux_ring.c
r8a63abd rebed638 252 252 char error[2048]; 253 253 254 /* Unmap any previous ring buffers associated with this stream. */ 255 if (stream->rx_ring != MAP_FAILED) { 256 munmap(stream->rx_ring, stream->req.tp_block_size * 257 stream->req.tp_block_nr); 258 stream->rx_ring = MAP_FAILED; 259 stream->rxring_offset = 0; 260 } 261 262 254 263 /* We set the socket up the same and then convert it to PACKET_MMAP */ 255 264 if (linuxcommon_start_input_stream(libtrace, stream) < 0) … … 274 283 return 0; 275 284 } 285 286 static int linuxring_fin_input(libtrace_t *libtrace) { 287 size_t i; 288 289 if (libtrace->format_data) { 290 for (i = 0; i < libtrace_list_get_size(FORMAT_DATA->per_stream); ++i) { 291 struct linux_per_stream_t *stream; 292 stream = libtrace_list_get_index( 293 FORMAT_DATA->per_stream, i)->data; 294 if (stream->rx_ring != MAP_FAILED) { 295 munmap(stream->rx_ring, 296 stream->req.tp_block_size * 297 stream->req.tp_block_nr); 298 } 299 } 300 301 if (FORMAT_DATA->filter != NULL) 302 free(FORMAT_DATA->filter); 303 304 if (FORMAT_DATA->per_stream) 305 libtrace_list_deinit(FORMAT_DATA->per_stream); 306 307 free(libtrace->format_data); 308 } 309 310 return 0; 311 } 312 276 313 277 314 static int linuxring_start_input(libtrace_t *libtrace) … … 622 659 /* If we own the packet (i.e. it's not a copy), we need to free it */ 623 660 if (packet->buf_control == TRACE_CTRL_EXTERNAL) { 624 /* Started should always match the existence of the rx_ring625 * in the parallel case still just check the first ring */626 assert(!!FORMAT_DATA_FIRST->rx_ring ==627 !!packet->trace->started);628 661 /* If we don't have a ring its already been destroyed */ 629 662 if (FORMAT_DATA_FIRST->rx_ring != MAP_FAILED) … … 742 775 NULL, /* config_output */ 743 776 linuxring_start_output, /* start_ouput */ 744 linux common_fin_input, /* fin_input */777 linuxring_fin_input, /* fin_input */ 745 778 linuxring_fin_output, /* fin_output */ 746 779 linuxring_read_packet, /* read_packet */
Note: See TracChangeset
for help on using the changeset viewer.