Procházet zdrojové kódy

Don't use buffered channels in the broker

It breaks the sync guarantees we need, and it doesn't result in async behaviour
at the client anyways (which was the original intention).
Evan Huus před 12 roky
rodič
revize
19132e333c
1 změnil soubory, kde provedl 2 přidání a 5 odebrání
  1. 2 5
      broker.go

+ 2 - 5
broker.go

@@ -173,13 +173,10 @@ func (b *broker) sendRequest(clientID *string, body encoder) (*responsePromise,
 	realEnc.putInt32(int32(prepEnc.length))
 	req.encode(&realEnc)
 
-	// we buffer one packet and one error so that all this can work async if the
-	// caller so desires. we also cheat and use the same responsePromise object for both the
-	// request and the response, as things are much simpler that way
-	request := responsePromise{b.correlation_id, make(chan []byte, 1), make(chan error, 1)}
+	request := responsePromise{b.correlation_id, make(chan []byte), make(chan error)}
 
-	request.packets <- realEnc.raw
 	b.requests <- request
+	request.packets <- realEnc.raw
 	b.correlation_id++
 	return &request, nil
 }