1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-05-04 11:39:08 -04:00

errors.Combine

This commit is contained in:
Darien Raymond
2018-12-04 14:17:08 +01:00
parent d4613f156b
commit bea521537e
6 changed files with 52 additions and 62 deletions

View File

@@ -139,9 +139,10 @@ func New(ctx context.Context, config *Config) (*Handler, error) {
// Close implements common.Closable.
func (h *Handler) Close() error {
return task.Run(
task.SequentialAll(
task.Close(h.clients), task.Close(h.sessionHistory), task.Close(h.usersByEmail)))()
return errors.Combine(
h.clients.Close(),
h.sessionHistory.Close(),
common.Close(h.usersByEmail))
}
// Network implements proxy.Inbound.Network().
@@ -290,9 +291,10 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection i
}
responseDone := func() error {
defer timer.SetTimeout(sessionPolicy.Timeouts.UplinkOnly)
writer := buf.NewBufferedWriter(buf.NewWriter(connection))
defer writer.Flush()
defer timer.SetTimeout(sessionPolicy.Timeouts.UplinkOnly)
response := &protocol.ResponseHeader{
Command: h.generateCommand(ctx, request),