mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 05:11:19 -04:00
Stop counting handlers before terminating.
The requirement to do so is obsolete and has already been removed from other pluggable transports. https://bugs.torproject.org/32046
This commit is contained in:
parent
d8d3170af8
commit
b4f4b29a03
4 changed files with 5 additions and 68 deletions
|
@ -21,10 +21,6 @@ var ptMethodName = "snowflake"
|
|||
var ptInfo pt.ServerInfo
|
||||
var logFile *os.File
|
||||
|
||||
// When a datachannel handler starts, +1 is written to this channel;
|
||||
// when it ends, -1 is written.
|
||||
var handlerChan = make(chan int)
|
||||
|
||||
func copyLoop(WebRTC, ORPort net.Conn) {
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(2)
|
||||
|
@ -100,11 +96,6 @@ func (c *webRTCConn) SetWriteDeadline(t time.Time) error {
|
|||
func datachannelHandler(conn *webRTCConn) {
|
||||
defer conn.Close()
|
||||
|
||||
handlerChan <- 1
|
||||
defer func() {
|
||||
handlerChan <- -1
|
||||
}()
|
||||
|
||||
or, err := pt.DialOr(&ptInfo, "", ptMethodName) // TODO: Extended OR
|
||||
if err != nil {
|
||||
log.Printf("Failed to connect to ORPort: " + err.Error())
|
||||
|
@ -246,8 +237,6 @@ func main() {
|
|||
}
|
||||
pt.SmethodsDone()
|
||||
|
||||
var numHandlers int
|
||||
var sig os.Signal
|
||||
sigChan := make(chan os.Signal, 1)
|
||||
signal.Notify(sigChan, syscall.SIGTERM)
|
||||
|
||||
|
@ -263,17 +252,6 @@ func main() {
|
|||
}()
|
||||
}
|
||||
|
||||
// keep track of handlers and wait for a signal
|
||||
sig = nil
|
||||
for sig == nil {
|
||||
select {
|
||||
case n := <-handlerChan:
|
||||
numHandlers += n
|
||||
case sig = <-sigChan:
|
||||
}
|
||||
}
|
||||
|
||||
for numHandlers > 0 {
|
||||
numHandlers += <-handlerChan
|
||||
}
|
||||
// wait for a signal
|
||||
<-sigChan
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue