1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-01-02 23:35:40 -05:00

refactor timer api

This commit is contained in:
Darien Raymond
2017-03-31 21:45:43 +02:00
parent a57531ef5d
commit f34ad57b58
11 changed files with 25 additions and 59 deletions

View File

@@ -121,14 +121,11 @@ func (s *Server) handleConnect(ctx context.Context, request *http.Request, reade
return errors.Base(err).Message("HTTP|Server: Failed to write back OK response.")
}
ctx, cancel := context.WithCancel(ctx)
defer cancel()
timeout := time.Second * time.Duration(s.config.Timeout)
if timeout == 0 {
timeout = time.Minute * 2
}
timer := signal.CancelAfterInactivity(ctx, cancel, timeout)
ctx, timer := signal.CancelAfterInactivity(ctx, timeout)
ray, err := dispatcher.Dispatch(ctx, dest)
if err != nil {
return err