()
| 480 | } |
| 481 | |
| 482 | func (tun *NativeTun) Close() error { |
| 483 | var err1, err2 error |
| 484 | tun.closeOnce.Do(func() { |
| 485 | if tun.statusListenersShutdown != nil { |
| 486 | close(tun.statusListenersShutdown) |
| 487 | if tun.netlinkCancel != nil { |
| 488 | err1 = tun.netlinkCancel.Cancel() |
| 489 | } |
| 490 | } else if tun.events != nil { |
| 491 | close(tun.events) |
| 492 | } |
| 493 | err2 = tun.tunFile.Close() |
| 494 | }) |
| 495 | if err1 != nil { |
| 496 | return err1 |
| 497 | } |
| 498 | return err2 |
| 499 | } |
| 500 | |
| 501 | func (tun *NativeTun) BatchSize() int { |
| 502 | return tun.batchSize |