command_conntrack.go 483 B

1234567891011121314151617181920212223242526
  1. package libbox
  2. import (
  3. "encoding/binary"
  4. "net"
  5. runtimeDebug "runtime/debug"
  6. "time"
  7. )
  8. func (c *CommandClient) CloseConnections() error {
  9. conn, err := c.directConnect()
  10. if err != nil {
  11. return err
  12. }
  13. defer conn.Close()
  14. return binary.Write(conn, binary.BigEndian, uint8(CommandCloseConnections))
  15. }
  16. func (s *CommandServer) handleCloseConnections(conn net.Conn) error {
  17. tracker.Close()
  18. go func() {
  19. time.Sleep(time.Second)
  20. runtimeDebug.FreeOSMemory()
  21. }()
  22. return nil
  23. }