mirror of
https://github.com/tailscale/tailscale.git
synced 2025-01-05 23:07:44 +00:00
tstest/natlab/vnet: flush and sync pcap file after every packet
So that we can view the pcap as we debug interactively. Updates #13038 Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
parent
978306565d
commit
31b5239a2f
@ -21,6 +21,15 @@ type pcapWriter struct {
|
||||
w *pcapgo.NgWriter
|
||||
}
|
||||
|
||||
func do(fs ...func() error) error {
|
||||
for _, f := range fs {
|
||||
if err := f(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *pcapWriter) WritePacket(ci gopacket.CaptureInfo, data []byte) error {
|
||||
if p == nil {
|
||||
return nil
|
||||
@ -30,7 +39,11 @@ func (p *pcapWriter) WritePacket(ci gopacket.CaptureInfo, data []byte) error {
|
||||
if p.w == nil {
|
||||
return io.ErrClosedPipe
|
||||
}
|
||||
return p.w.WritePacket(ci, data)
|
||||
return do(
|
||||
func() error { return p.w.WritePacket(ci, data) },
|
||||
p.w.Flush,
|
||||
p.f.Sync,
|
||||
)
|
||||
}
|
||||
|
||||
func (p *pcapWriter) AddInterface(i pcapgo.NgInterface) (int, error) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user