File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed
Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -103,7 +103,9 @@ func (wbrc *Archiver) Wayback(links []string) (map[string]string, error) {
103103 wg .Wait ()
104104
105105 // Close tor connection
106- done <- true
106+ defer func () {
107+ done <- true
108+ }()
107109
108110 if len (results ) == 0 {
109111 return results , fmt .Errorf ("No results" )
@@ -154,6 +156,11 @@ func (wbrc *Archiver) Playback(links []string) (map[string]string, error) {
154156 }
155157 wg .Wait ()
156158
159+ // Close tor connection
160+ defer func () {
161+ done <- true
162+ }()
163+
157164 if len (results ) == 0 {
158165 return results , fmt .Errorf ("No results" )
159166 }
Original file line number Diff line number Diff line change @@ -54,18 +54,14 @@ func newTorClient(done <-chan bool) (*http.Client, error) {
5454 }
5555
5656 go func () {
57- // Auto close tor client after 10 min
58- tick := time .NewTicker (10 * time .Minute )
5957 for {
6058 select {
6159 case <- done :
6260 logger .Debug ("Closed tor client" )
63- tick .Stop ()
6461 t .Close ()
6562 return
66- case <- tick . C :
63+ case <- time . After ( 10 * time . Minute ) :
6764 logger .Debug ("Closed tor client, timeout" )
68- tick .Stop ()
6965 t .Close ()
7066 return
7167 default :
You can’t perform that action at this time.
0 commit comments