Skip to content

Commit

Permalink
Do not make setup transport managed in acceptTransport
Browse files Browse the repository at this point in the history
  • Loading branch information
nkryuchkov committed Jul 19, 2019
1 parent 6ba5818 commit 54cdc33
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
33 changes: 16 additions & 17 deletions pkg/transport/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ func (tm *Manager) dialTransport(ctx context.Context, factory Factory, remote ci
return tr, entry, nil
}

func (tm *Manager) acceptTransport(ctx context.Context, factory Factory) (*ManagedTransport, error) {
func (tm *Manager) acceptTransport(ctx context.Context, factory Factory) (Transport, error) {
tr, err := factory.Accept(ctx)
if err != nil {
return nil, err
Expand Down Expand Up @@ -409,28 +409,27 @@ func (tm *Manager) acceptTransport(ctx context.Context, factory Factory) (*Manag
oldTr.killWorker()
}

if isSetup {
select {
case <-tm.doneChan:
return nil, io.ErrClosedPipe
case tm.SetupTpChan <- tr:
return tr, nil
}
}

mTr := newManagedTransport(tr, *entry, true)

tm.mu.Lock()
tm.transports[entry.ID] = mTr
tm.mu.Unlock()

if isSetup {
select {
case <-tm.doneChan:
return nil, io.ErrClosedPipe
case tm.SetupTpChan <- mTr:
go tm.manageTransport(ctx, mTr, factory, remote)
return mTr, nil
}
} else {
select {
case <-tm.doneChan:
return nil, io.ErrClosedPipe
case tm.DataTpChan <- mTr:
go tm.manageTransport(ctx, mTr, factory, remote)
return mTr, nil
}
select {
case <-tm.doneChan:
return nil, io.ErrClosedPipe
case tm.DataTpChan <- mTr:
go tm.manageTransport(ctx, mTr, factory, remote)
return mTr, nil
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/transport/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ func ExampleMakeTransportID() {
// uuid is different for public and private transports
}

func ExampleManager_CreateTransport() {
func ExampleManager_CreateDataTransport() {
// Repetition is required here to guarantee that correctness does not depends on order of edges
for i := 0; i < 4; i++ {
pkB, mgrA, err := MockTransportManager()
Expand Down

0 comments on commit 54cdc33

Please sign in to comment.