1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-07-03 21:08:17 +08:00

fix(net/mux) rate-limit producers by handling outgoing message synchronously

License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
This commit is contained in:
Brian Tiger Chow
2014-12-02 01:14:15 -08:00
parent 0f6b1bc73e
commit 1026244f13

View File

@ -174,8 +174,7 @@ func (m *Muxer) handleOutgoingMessages(pid pb.ProtocolID, proto Protocol) {
if !more { if !more {
return return
} }
m.Children().Add(1) m.handleOutgoingMessage(pid, msg)
go m.handleOutgoingMessage(pid, msg)
case <-m.Closing(): case <-m.Closing():
return return
@ -185,7 +184,6 @@ func (m *Muxer) handleOutgoingMessages(pid pb.ProtocolID, proto Protocol) {
// handleOutgoingMessage wraps out a message and sends it out the // handleOutgoingMessage wraps out a message and sends it out the
func (m *Muxer) handleOutgoingMessage(pid pb.ProtocolID, m1 msg.NetMessage) { func (m *Muxer) handleOutgoingMessage(pid pb.ProtocolID, m1 msg.NetMessage) {
defer m.Children().Done()
data, err := wrapData(m1.Data(), pid) data, err := wrapData(m1.Data(), pid)
if err != nil { if err != nil {