()
| 714 | } |
| 715 | |
| 716 | func (c *rawConnection) writerLoop() { |
| 717 | select { |
| 718 | case cc := <-c.clusterConfigBox: |
| 719 | err := c.writeMessage(cc.toWire()) |
| 720 | if err != nil { |
| 721 | c.internalClose(err) |
| 722 | return |
| 723 | } |
| 724 | case hm := <-c.closeBox: |
| 725 | _ = c.writeMessage(hm.msg) |
| 726 | close(hm.done) |
| 727 | return |
| 728 | case <-c.closed: |
| 729 | return |
| 730 | } |
| 731 | for { |
| 732 | // When the connection is closing or closed, that should happen |
| 733 | // immediately, not compete with the (potentially very busy) outbox. |
| 734 | select { |
| 735 | case hm := <-c.closeBox: |
| 736 | _ = c.writeMessage(hm.msg) |
| 737 | close(hm.done) |
| 738 | return |
| 739 | case <-c.closed: |
| 740 | return |
| 741 | default: |
| 742 | } |
| 743 | select { |
| 744 | case cc := <-c.clusterConfigBox: |
| 745 | err := c.writeMessage(cc.toWire()) |
| 746 | if err != nil { |
| 747 | c.internalClose(err) |
| 748 | return |
| 749 | } |
| 750 | case hm := <-c.outbox: |
| 751 | err := c.writeMessage(hm.msg) |
| 752 | if hm.done != nil { |
| 753 | close(hm.done) |
| 754 | } |
| 755 | if err != nil { |
| 756 | c.internalClose(err) |
| 757 | return |
| 758 | } |
| 759 | |
| 760 | case hm := <-c.closeBox: |
| 761 | _ = c.writeMessage(hm.msg) |
| 762 | close(hm.done) |
| 763 | return |
| 764 | |
| 765 | case <-c.closed: |
| 766 | return |
| 767 | } |
| 768 | } |
| 769 | } |
| 770 | |
| 771 | func (c *rawConnection) writeMessage(msg proto.Message) error { |
| 772 | msgContext, _ := messageContext(msg) |
no test coverage detected