diff options
| author | Bryan Matsuo <[email protected]> | 2014-12-04 18:09:24 -0800 |
|---|---|---|
| committer | Andrew Gallant <[email protected]> | 2015-04-26 17:53:56 -0400 |
| commit | 7fc5ee5088f1fcccec03759b699768dc5cff325d (patch) | |
| tree | 0e0cf34f69601a5326e3f1a718fbfc53061fe29f | |
| parent | e4ac47f3a521f0bdc30fbd5e263b14d0218bbf62 (diff) | |
assign a sequence id to the cookie before returning from Conn.NewRequest
| -rw-r--r-- | xgb.go | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -290,6 +290,9 @@ func (c *Conn) generateSeqIds() { type request struct { buf []byte cookie *Cookie + + // seq is closed when the request (cookie) has been sequenced by the Conn. + seq chan struct{} } // NewRequest takes the bytes and a cookie of a particular request, constructs @@ -311,7 +314,9 @@ type request struct { // In all likelihood, you should be able to copy and paste with some minor // edits the generated code for the request you want to issue. func (c *Conn) NewRequest(buf []byte, cookie *Cookie) { - c.reqChan <- &request{buf: buf, cookie: cookie} + seq := make(chan struct{}) + c.reqChan <- &request{buf: buf, cookie: cookie, seq: seq} + <-seq } // sendRequests is run as a single goroutine that takes requests and writes @@ -329,6 +334,7 @@ func (c *Conn) sendRequests() { c.noop() } req.cookie.Sequence = c.newSequenceId() + close(req.seq) c.cookieChan <- req.cookie c.writeBuffer(req.buf) } |
