mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-04 04:30:05 +00:00
fix: only close user/agentIo connect channel once (#21)
This commit is contained in:
@@ -15,6 +15,8 @@ type ioStreamContext struct {
|
||||
agentIo io.ReadWriteCloser
|
||||
userIoConnectCh chan struct{}
|
||||
agentIoConnectCh chan struct{}
|
||||
userIoChOnce sync.Once
|
||||
agentIoChOnce sync.Once
|
||||
}
|
||||
|
||||
type bp struct {
|
||||
@@ -74,7 +76,9 @@ func (s *NezhaHandler) UserConnected(streamId string, userIo io.ReadWriteCloser)
|
||||
}
|
||||
|
||||
stream.userIo = userIo
|
||||
close(stream.userIoConnectCh)
|
||||
stream.userIoChOnce.Do(func() {
|
||||
close(stream.userIoConnectCh)
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -86,7 +90,9 @@ func (s *NezhaHandler) AgentConnected(streamId string, agentIo io.ReadWriteClose
|
||||
}
|
||||
|
||||
stream.agentIo = agentIo
|
||||
close(stream.agentIoConnectCh)
|
||||
stream.agentIoChOnce.Do(func() {
|
||||
close(stream.agentIoConnectCh)
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user