Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix timer leak #587

Merged
merged 1 commit into from
Oct 6, 2017
Merged

fix timer leak #587

merged 1 commit into from
Oct 6, 2017

Conversation

ghv2
Copy link
Contributor

@ghv2 ghv2 commented Oct 6, 2017

The following code leads to timer leak. defer ticker.Stop() cannot stop the new ticker because of different addresses. The patch fixes this bug.

case timeout := <-t.timeout:
 			ticker.Stop()
 			ticker = time.NewTicker(timeout)

@codecov
Copy link

codecov bot commented Oct 6, 2017

Codecov Report

Merging #587 into master will decrease coverage by 0.14%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #587      +/-   ##
==========================================
- Coverage   71.83%   71.69%   -0.15%     
==========================================
  Files         185      185              
  Lines        8551     8553       +2     
==========================================
- Hits         6143     6132      -11     
- Misses       1854     1862       +8     
- Partials      554      559       +5
Impacted Files Coverage Δ
common/signal/timer.go 100% <100%> (ø) ⬆️
transport/internet/websocket/connection.go 51.11% <0%> (-8.89%) ⬇️
common/buf/copy.go 60.41% <0%> (-8.34%) ⬇️
app/proxyman/mux/session.go 83.07% <0%> (-4.62%) ⬇️
proxy/vmess/outbound/outbound.go 77.27% <0%> (-2.28%) ⬇️
proxy/shadowsocks/server.go 62.93% <0%> (-1.73%) ⬇️
app/proxyman/mux/mux.go 68.64% <0%> (-0.85%) ⬇️
proxy/socks/protocol.go 55.01% <0%> (-0.65%) ⬇️
proxy/socks/server.go 77.98% <0%> (ø) ⬆️
transport/internet/kcp/connection.go 74.78% <0%> (+0.58%) ⬆️
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b862365...0ef745d. Read the comment docs.

Copy link
Contributor

@DarienRaymond DarienRaymond left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for noticing. The change is good. However, I prefer to keep 'defer' instead of using 'goto' or 'break'. For example:

defer func() {
  ticker.stop()
}()

POC: https://play.golang.org/p/BoNQU982zu

@DarienRaymond DarienRaymond merged commit 1dcf3aa into v2ray:master Oct 6, 2017
@DarienRaymond
Copy link
Contributor

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants