gate send actions based on whether the peer is connected.
This commit is contained in:
+8
-1
@@ -292,6 +292,7 @@ func (m *RequestManager) Cancel(id string) error {
|
||||
}
|
||||
|
||||
if req.active {
|
||||
if m.envoy.IsConnected() {
|
||||
go func() {
|
||||
err := m.envoy.Send(envelope.EncloseClose(id))
|
||||
if err != nil {
|
||||
@@ -304,6 +305,7 @@ func (m *RequestManager) Cancel(id string) error {
|
||||
m.logger.Debug("close sent", "req", req.id)
|
||||
}
|
||||
}()
|
||||
}
|
||||
req.active = false
|
||||
}
|
||||
|
||||
@@ -324,7 +326,7 @@ func (m *RequestManager) Close() {
|
||||
defer m.mu.Unlock()
|
||||
|
||||
for id, req := range m.reqs {
|
||||
if req.active {
|
||||
if m.envoy.IsConnected() && req.active {
|
||||
go m.envoy.Send(envelope.EncloseClose(id))
|
||||
}
|
||||
req.deregisterOnce.Do(func() {
|
||||
@@ -336,6 +338,9 @@ func (m *RequestManager) Close() {
|
||||
}
|
||||
|
||||
func (m *RequestManager) activate(req *request) {
|
||||
if !m.envoy.IsConnected() {
|
||||
return
|
||||
}
|
||||
req.active = true
|
||||
go func() {
|
||||
err := m.envoy.Send(envelope.EncloseReq(req.id, req.filters))
|
||||
@@ -477,6 +482,7 @@ func (m *RequestManager) routeEOSE(msg InboxMessage) {
|
||||
req.active = false
|
||||
close(req.buffer)
|
||||
delete(m.reqs, req.id)
|
||||
if m.envoy.IsConnected() {
|
||||
go func() {
|
||||
err := m.envoy.Send(envelope.EncloseClose(subID))
|
||||
if err != nil {
|
||||
@@ -491,6 +497,7 @@ func (m *RequestManager) routeEOSE(msg InboxMessage) {
|
||||
}()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (m *RequestManager) routeClosed(msg InboxMessage) {
|
||||
subID, message, err := envelope.FindClosed(msg.Data)
|
||||
|
||||
Reference in New Issue
Block a user