Skip to content

Commit

Permalink
fix #1338
Browse files Browse the repository at this point in the history
  • Loading branch information
DarienRaymond committed Oct 27, 2018
1 parent 8595bce commit 6c89940
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions common/mux/server.go
Expand Up @@ -44,15 +44,14 @@ func (s *Server) Dispatch(ctx context.Context, dest net.Destination) (*vio.Link,
uplinkReader, uplinkWriter := pipe.New(opts...)
downlinkReader, downlinkWriter := pipe.New(opts...)

worker := &ServerWorker{
dispatcher: s.dispatcher,
link: &vio.Link{
Reader: uplinkReader,
Writer: downlinkWriter,
},
sessionManager: NewSessionManager(),
_, err := NewServerWorker(ctx, s.dispatcher, &vio.Link{
Reader: uplinkReader,
Writer: downlinkWriter,
})
if err != nil {
return nil, err
}
go worker.run(ctx)

return &vio.Link{Reader: downlinkReader, Writer: uplinkWriter}, nil
}

Expand All @@ -72,6 +71,16 @@ type ServerWorker struct {
sessionManager *SessionManager
}

func NewServerWorker(ctx context.Context, d routing.Dispatcher, link *vio.Link) (*ServerWorker, error) {
worker := &ServerWorker{
dispatcher: d,
link: link,
sessionManager: NewSessionManager(),
}
go worker.run(ctx)
return worker, nil
}

func handle(ctx context.Context, s *Session, output buf.Writer) {
writer := NewResponseWriter(s.ID, output, s.transferType)
if err := buf.Copy(s.input, writer); err != nil {
Expand Down Expand Up @@ -142,7 +151,7 @@ func (w *ServerWorker) handleStatusKeep(meta *FrameMetadata, reader *buf.Buffere

s, found := w.sessionManager.Get(meta.SessionID)
if !found {
buf.Copy(NewStreamReader(reader), buf.Discard)
return buf.Copy(NewStreamReader(reader), buf.Discard)
}

rr := s.NewReader(reader)
Expand Down

0 comments on commit 6c89940

Please sign in to comment.