Ticket #29559: 0001-Look-for-EOF-on-stdin-while-grepping-for-the-helper-.patch

File 0001-Look-for-EOF-on-stdin-while-grepping-for-the-helper-.patch, 1.4 KB (added by dcf, 6 months ago)
  • meek-client-torbrowser/meek-client-torbrowser.go

    From 01ea27b4c59cd8ae17e608006cd7a9a16ba282c4 Mon Sep 17 00:00:00 2001
    From: David Fifield <david@bamsoftware.com>
    Date: Sat, 23 Feb 2019 00:23:51 -0700
    Subject: [PATCH] Look for EOF on stdin while grepping for the helper address.
    
    This way, we still exit when the parent process dies, even if for
    whatever reason Firefox doesn't give us a helper address.
    
    https://bugs.torproject.org/29559
    ---
     meek-client-torbrowser/meek-client-torbrowser.go | 19 +++++++++++++++++--
     1 file changed, 17 insertions(+), 2 deletions(-)
    
    diff --git a/meek-client-torbrowser/meek-client-torbrowser.go b/meek-client-torbrowser/meek-client-torbrowser.go
    index f3ffc68..16f0ebc 100644
    a b func main() { 
    370370        defer logKill(firefoxCmd.Process)
    371371
    372372        // Find out the helper's listening address.
    373         helperAddr, err := grepHelperAddr(stdout)
    374         if err != nil {
     373        addrChan := make(chan string)
     374        errChan := make(chan error)
     375        go func() {
     376                addr, err := grepHelperAddr(stdout)
     377                if err == nil {
     378                        addrChan <- addr
     379                } else {
     380                        errChan <- err
     381                }
     382        }()
     383        var helperAddr string
     384        select {
     385        case sig := <-sigChan:
     386                log.Printf("sig %s", sig)
     387                return
     388        case err = <-errChan:
    375389                log.Print(err)
    376390                return
     391        case helperAddr = <-addrChan:
    377392        }
    378393
    379394        // Start meek-client with the helper address.