Compare commits

...

3 Commits
v0.0.4 ... main

Author SHA1 Message Date
Sense T
7662ab4e08 fix bug 2022-09-10 10:44:27 +00:00
Sense T
8c2b78e30b bug fix 2022-09-10 09:51:30 +00:00
Sense T
6002e20080 safer close 2022-09-10 02:19:17 +00:00
2 changed files with 18 additions and 20 deletions

View File

@ -22,22 +22,17 @@ type Logger interface {
type logger struct{}
func (l *logger) Trace(args ...interface{})
func (l *logger) Tracef(format string, args ...interface{})
func (l *logger) Debug(args ...interface{})
func (l *logger) Debugf(format string, args ...interface{})
func (l *logger) Info(args ...interface{})
func (l *logger) Infof(format string, args ...interface{})
func (l *logger) Error(args ...interface{})
func (l *logger) Errorf(format string, args ...interface{})
func (l *logger) Fatal(args ...interface{})
func (l *logger) Fatalf(format string, args ...interface{})
func (l *logger) Panic(args ...interface{})
func (l *logger) Panicf(format string, args ...interface{})
func (l *logger) Trace(args ...interface{}) {}
func (l *logger) Tracef(format string, args ...interface{}) {}
func (l *logger) Debug(args ...interface{}) {}
func (l *logger) Debugf(format string, args ...interface{}) {}
func (l *logger) Info(args ...interface{}) {}
func (l *logger) Infof(format string, args ...interface{}) {}
func (l *logger) Error(args ...interface{}) {}
func (l *logger) Errorf(format string, args ...interface{}) {}
func (l *logger) Fatal(args ...interface{}) {}
func (l *logger) Fatalf(format string, args ...interface{}) {}
func (l *logger) Panic(args ...interface{}) {}
func (l *logger) Panicf(format string, args ...interface{}) {}
var DefaultLogger = &logger{}

View File

@ -25,6 +25,7 @@ func NewManager(tun io.ReadWriter) *Manager {
accept: make(chan *DataFrame, 1024),
newConnection: make(chan *Connection),
delConnection: make(chan *Connection),
closed: make(chan bool),
logger: DefaultLogger,
}
}
@ -47,9 +48,11 @@ func (m *Manager) Run() {
m.Connections[connection.ID] = connection
m.logger.Tracef("connection '%s' registered", connection.ID)
case connection := <-m.delConnection:
connection.Close()
delete(m.Connections, connection.ID)
m.logger.Tracef("connection '%s' unregistered", connection.ID)
if !connection.closed {
connection.Close()
delete(m.Connections, connection.ID)
m.logger.Tracef("connection '%s' unregistered", connection.ID)
}
case onReceiveQueue <- true:
go m.onReceive(onReceiveQueue)
}