Skip to content

Commit

Permalink
Fix compilation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
gz-c committed May 25, 2019
1 parent 95cbf46 commit f771869
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pkg/messaging/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,18 +153,20 @@ func (mCh *msgChannel) Write(p []byte) (n int, err error) {
}
}

func (mCh *msgChannel) RequestClose() error {
func (mCh *msgChannel) Close() error {
select {
case <-mCh.doneChan:
return ErrChannelClosed
default:
}

if _, err := mCh.link.SendCloseChannel(mCh.ID()); err != nil {
return err
if mCh.close() {
if _, err := mCh.link.SendCloseChannel(mCh.ID()); err != nil {
return err
}
}

mCh.close()
return nil
}

func (mCh *msgChannel) SetDeadline(t time.Time) error {
Expand All @@ -183,7 +185,7 @@ func (mCh *msgChannel) OnChannelClosed() bool {
func (mCh *msgChannel) close() bool {
closed := false
mCh.doneOnce.Do(func() {
close(mc.doneChan)
close(mCh.doneChan)
closed = true
})
return closed
Expand Down

0 comments on commit f771869

Please sign in to comment.