Skip to content

Commit

Permalink
Correct issue where StartStream callback could be invoked multiple ti…
Browse files Browse the repository at this point in the history
…mes.

Change-Id: I9012973a2cf50366ec8f2f846085c0ac5880edfe
Reviewed-on: http://review.couchbase.org/63827
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Tested-by: Brett Lawson <brett19@gmail.com>
  • Loading branch information
brett19 committed May 17, 2016
1 parent 2997f2a commit b1c6616
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions gocbcore/agentops_dcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,13 @@ type GetVBucketSeqnosCallback func(uint16, SeqNo, error)
func (c *Agent) OpenStream(vbId uint16, vbUuid VbUuid, startSeqNo, endSeqNo, snapStartSeqNo, snapEndSeqNo SeqNo, evtHandler StreamObserver, cb OpenStreamCallback) (PendingOp, error) {
var req *memdQRequest
handler := func(resp *memdResponse, err error) {
if err != nil {
// All client errors are handled by the StreamObserver
cb(nil, err)
return
}

if resp.Magic == ResMagic {
// This is the response to the open stream request.
if err != nil {
// All client errors are handled by the StreamObserver
cb(nil, err)
return
}

numEntries := len(resp.Value) / 16
entries := make([]FailoverEntry, numEntries)
Expand All @@ -63,6 +62,11 @@ func (c *Agent) OpenStream(vbId uint16, vbUuid VbUuid, startSeqNo, endSeqNo, sna
return
}

if err != nil {
evtHandler.End(vbId, err)
return
}

// This is one of the stream events
switch resp.Opcode {
case CmdDcpSnapshotMarker:
Expand Down

0 comments on commit b1c6616

Please sign in to comment.