File tree Expand file tree Collapse file tree 1 file changed +18
-9
lines changed
Expand file tree Collapse file tree 1 file changed +18
-9
lines changed Original file line number Diff line number Diff line change 1717package channel
1818
1919import (
20+ "errors"
2021 "sync"
2122
2223 "github.com/michaelquigley/pfxlog"
@@ -42,7 +43,10 @@ func (self *MultiListener) AcceptUnderlay(underlay Underlay) {
4243
4344 if ! isGrouped {
4445 if err := self .ungroupedChannelFallback (underlay ); err != nil {
45- log .WithError (err ).Errorf ("failed to create channel" )
46+ log .WithError (err ).Error ("failed to create channel" )
47+ if closeErr := underlay .Close (); closeErr != nil {
48+ log .WithError (closeErr ).Error ("error closing underlay" )
49+ }
4650 }
4751 return
4852 }
@@ -63,7 +67,7 @@ func (self *MultiListener) AcceptUnderlay(underlay Underlay) {
6367 if ! isFirst {
6468 log .Info ("no existing channel found for underlay, but isFirstGroupConnection not set, closing connection" )
6569 if err := underlay .Close (); err != nil {
66- log .Info ("error closing underlay" )
70+ log .WithError ( err ). Error ("error closing underlay" )
6771 }
6872 return
6973 }
@@ -74,14 +78,19 @@ func (self *MultiListener) AcceptUnderlay(underlay Underlay) {
7478 self .CloseChannel (chId )
7579 })
7680
77- if mc != nil {
78- if err != nil {
79- log .WithError (err ).Errorf ("failed to create multi-underlay channel" )
80- } else {
81- self .lock .Lock ()
82- self .channels [chId ] = mc
83- self .lock .Unlock ()
81+ if mc == nil && err == nil {
82+ err = errors .New ("multi-channel factory returned nil" )
83+ }
84+
85+ if err != nil {
86+ log .WithError (err ).Error ("failed to create multi-underlay channel" )
87+ if closeErr := underlay .Close (); closeErr != nil {
88+ log .WithError (closeErr ).Error ("error closing underlay" )
8489 }
90+ } else {
91+ self .lock .Lock ()
92+ self .channels [chId ] = mc
93+ self .lock .Unlock ()
8594 }
8695 }
8796}
You can’t perform that action at this time.
0 commit comments