-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
create UDP connection only when needed #825
Conversation
Changed the logging items to let them more clear:
|
@xtaci Now that only when Line 459 in e9316f7
So a question is that should we update option |
|
@xtaci Ok, make sense to me. This PR is ready for review, please let me know if any adjust needed |
why setting nil for line 440 |
@xtaci Set sessions to nil when make the pool is because 1) there may no soon traffic coming to kcptun-client when it starts up and 2) make session's creation only happens in a single place (create only when a TCP conn accepted) which makes a better readability. |
sessionList = append(sessionList, timedSession{ | ||
sess, | ||
time.Now().Add(time.Duration(config.ScavengeTTL+config.AutoExpire) * time.Second)}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here in scavenger(), we better not depend on config.AutoExpire
, instead to fetch the expire info from the session item. So that a change to the timedSession.expiryDate
built logic won't need to touch the code in scavenger too.
@@ -152,7 +152,7 @@ GLOBAL OPTIONS: | |||
--mode value profiles: fast3, fast2, fast, normal, manual (default: "fast") | |||
--conn value set num of UDP connections to server (default: 1) | |||
--autoexpire value set auto expiration time(in seconds) for a single UDP connection, 0 to disable (default: 0) | |||
--scavengettl value set how long an expired connection can live(in sec), -1 to disable (default: 600) | |||
--scavengettl value set how long an expired connection can live (in seconds) (default: 600) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any place of using -1
, so I guess the description need to be updated?
@xtaci I just updated a bit more. It's ready for another look. Please let me know if you'd like to do any adjustments. |
Line 439-442 can be delete for lazy initialization of session |
@xtaci hmm, good point. Updated. |
looks good to me . |
A further step to try to fix #802