Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix Compare and swap returns incorrect cause #614

Merged
merged 1 commit into from
Mar 11, 2014
Merged

fix Compare and swap returns incorrect cause #614

merged 1 commit into from
Mar 11, 2014

Conversation

metaflow
Copy link
Contributor

@metaflow metaflow commented Mar 7, 2014

fix for issue #611

Note that compare-and-delete cause changed too.
I worry about modifications in v1 tests while v1 API is frozen.

Thank you!

@@ -322,10 +322,15 @@ func (n *node) UpdateTTL(expireTime time.Time) {
}

func (n *node) Compare(prevValue string, prevIndex uint64) bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@metaflow Can you change this to return (ok bool, which int).
So you do not need to compare it again in getCompareFailCause.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xiangli-cmu sure
for for both match which = 0
only index match - 1
only value match - 2
both mismatch - 3
sounds good?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add const variables for these const numbers? Like

const (
  match = 0
  indexNotMatch = 1
  valueNotMatch = 2
  NoMatch =3
)

I think we can just use positive number. 1 for index not match, 2 for value not match, and 3 for neither of them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xiangli-cmu one more question - it should be added as exported const in header of this file, shouldn't it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@metaflow Oh. Yes. since the function is exported.

@xiang90
Copy link
Contributor

xiang90 commented Mar 7, 2014

@metaflow Thank you for working on this!

@metaflow
Copy link
Contributor Author

metaflow commented Mar 7, 2014

@xiangli-cmu I have changed result of Compare and added constants

@xiang90
Copy link
Contributor

xiang90 commented Mar 7, 2014

lgtm

@xiang90
Copy link
Contributor

xiang90 commented Mar 8, 2014

Can you squash these commits?
/cc @philips

specifically when both prevIndex and prevValue are provided
@metaflow
Copy link
Contributor Author

metaflow commented Mar 8, 2014

@xiangli-cmu @philips done, fixed commit message as well

@metaflow
Copy link
Contributor Author

metaflow commented Mar 8, 2014

I will update API docs in another PR if you don't mind (I already have #610 not merged yet :) so I can add this there)

@philips
Copy link
Contributor

philips commented Mar 11, 2014

lgtm, merging.

philips added a commit that referenced this pull request Mar 11, 2014
fix Compare and swap returns incorrect cause
@philips philips merged commit 0ea6141 into etcd-io:master Mar 11, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants