return -81; /* VNET_API_ERROR_VALUE_EXIST */
/* Change number of packets to capture while capturing */
- if (vm->dispatch_pcap_enable
+ if (vm->dispatch_pcap_enable && a->enable
&& (pm->n_packets_to_capture != a->packets_to_capture))
return -8; /* VNET_API_ERROR_INVALID_VALUE_2 */
vlib_cli_output (vm, "Write %d packets to %s, and stop capture...",
pm->n_packets_captured, pm->file_name);
error = pcap_write (pm);
- if (pm->file_descriptor >= 0)
+ if (pm->flags & PCAP_MAIN_INIT_DONE)
pcap_close (pm);
/* Report I/O errors... */
if (error)