Revert "protect socket variable with mutex; fix #437"
This reverts commit 1b7ce4c378
.
This commit is contained in:
parent
1b7ce4c378
commit
2a26215f2a
1 changed files with 2 additions and 15 deletions
|
@ -49,7 +49,6 @@ func (cfg Config) LogFields() log.Fields {
|
||||||
// Frontend holds the state of a UDP BitTorrent Frontend.
|
// Frontend holds the state of a UDP BitTorrent Frontend.
|
||||||
type Frontend struct {
|
type Frontend struct {
|
||||||
socket *net.UDPConn
|
socket *net.UDPConn
|
||||||
m sync.Mutex
|
|
||||||
closing chan struct{}
|
closing chan struct{}
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
|
|
||||||
|
@ -104,20 +103,10 @@ func (t *Frontend) Stop() stop.Result {
|
||||||
|
|
||||||
c := make(stop.Channel)
|
c := make(stop.Channel)
|
||||||
go func() {
|
go func() {
|
||||||
t.m.Lock()
|
|
||||||
defer t.m.Unlock()
|
|
||||||
|
|
||||||
close(t.closing)
|
close(t.closing)
|
||||||
if t.socket != nil {
|
t.socket.SetReadDeadline(time.Now())
|
||||||
t.socket.SetReadDeadline(time.Now())
|
|
||||||
}
|
|
||||||
t.wg.Wait()
|
t.wg.Wait()
|
||||||
|
c.Done(t.socket.Close())
|
||||||
var err error
|
|
||||||
if t.socket != nil {
|
|
||||||
err = t.socket.Close()
|
|
||||||
}
|
|
||||||
c.Done(err)
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
return c.Result()
|
return c.Result()
|
||||||
|
@ -131,9 +120,7 @@ func (t *Frontend) listenAndServe() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
t.m.Lock()
|
|
||||||
t.socket, err = net.ListenUDP("udp", udpAddr)
|
t.socket, err = net.ListenUDP("udp", udpAddr)
|
||||||
t.m.Unlock()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue