Skip to content

Commit 1db9edb

Browse files
committed
Minor improvement
1 parent 15cdbe6 commit 1db9edb

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

is.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff 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
}

tor.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff 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:

0 commit comments

Comments
 (0)