gotd: assume any response is an ack
This commit is contained in:
+6
-4
@@ -10,11 +10,13 @@ func (e *Engine) NotifyAcks(ids []int64) {
|
|||||||
defer e.mux.Unlock()
|
defer e.mux.Unlock()
|
||||||
|
|
||||||
for _, id := range ids {
|
for _, id := range ids {
|
||||||
ch, ok := e.ack[id]
|
e.notifyAckUnlocked(id)
|
||||||
if !ok {
|
}
|
||||||
continue
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
func (e *Engine) notifyAckUnlocked(id int64) {
|
||||||
|
ch, ok := e.ack[id]
|
||||||
|
if ok {
|
||||||
close(ch)
|
close(ch)
|
||||||
delete(e.ack, id)
|
delete(e.ack, id)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -231,6 +231,7 @@ func (e *Engine) retryUntilAck(ctx context.Context, req Request) (sent bool, err
|
|||||||
// NotifyResult notifies engine about received RPC response.
|
// NotifyResult notifies engine about received RPC response.
|
||||||
func (e *Engine) NotifyResult(msgID int64, b *bin.Buffer) error {
|
func (e *Engine) NotifyResult(msgID int64, b *bin.Buffer) error {
|
||||||
e.mux.Lock()
|
e.mux.Lock()
|
||||||
|
e.notifyAckUnlocked(msgID)
|
||||||
fn, ok := e.rpc[msgID]
|
fn, ok := e.rpc[msgID]
|
||||||
e.mux.Unlock()
|
e.mux.Unlock()
|
||||||
if !ok {
|
if !ok {
|
||||||
@@ -245,6 +246,7 @@ func (e *Engine) NotifyResult(msgID int64, b *bin.Buffer) error {
|
|||||||
func (e *Engine) NotifyError(msgID int64, rpcErr error) {
|
func (e *Engine) NotifyError(msgID int64, rpcErr error) {
|
||||||
e.onError(rpcErr)
|
e.onError(rpcErr)
|
||||||
e.mux.Lock()
|
e.mux.Lock()
|
||||||
|
e.notifyAckUnlocked(msgID)
|
||||||
fn, ok := e.rpc[msgID]
|
fn, ok := e.rpc[msgID]
|
||||||
e.mux.Unlock()
|
e.mux.Unlock()
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|||||||
Reference in New Issue
Block a user