浏览代码

Merge branch 'master' of https://github.com/v2ray/v2ray-core

Darien Raymond 8 年之前
父节点
当前提交
d10445d49a
共有 1 个文件被更改,包括 8 次插入0 次删除
  1. 8 0
      app/proxyman/mux/mux.go

+ 8 - 0
app/proxyman/mux/mux.go

@@ -205,6 +205,13 @@ func fetchInput(ctx context.Context, s *session, output buf.Writer) {
 	}
 	}
 }
 }
 
 
+func waitForDone(ctx context.Context, s *session) {
+	<-ctx.Done()
+	s.closeUplink()
+	s.closeDownlink()
+	s.output.Close()
+}
+
 func (m *Client) Dispatch(ctx context.Context, outboundRay ray.OutboundRay) bool {
 func (m *Client) Dispatch(ctx context.Context, outboundRay ray.OutboundRay) bool {
 	m.access.Lock()
 	m.access.Lock()
 	defer m.access.Unlock()
 	defer m.access.Unlock()
@@ -233,6 +240,7 @@ func (m *Client) Dispatch(ctx context.Context, outboundRay ray.OutboundRay) bool
 	}
 	}
 	m.sessions[id] = s
 	m.sessions[id] = s
 	go fetchInput(ctx, s, m.inboundRay.InboundInput())
 	go fetchInput(ctx, s, m.inboundRay.InboundInput())
+	go waitForDone(ctx, s)
 	return true
 	return true
 }
 }