diff options
author | Jeff Darcy <jdarcy@redhat.com> | 2014-01-14 15:30:47 +0000 |
---|---|---|
committer | Jeff Darcy <jdarcy@redhat.com> | 2014-01-14 17:15:28 +0000 |
commit | 47c548f7dd70457f4ea5816965b12008697d0f1e (patch) | |
tree | aa47a19f427abefa21baa6b2e103070c3cd21f4c | |
parent | e0cce4cf7c22d5cd8ab6c2aff4ecf28c18c6a469 (diff) |
Fix precondition handling.
Without this, nsr.t was hanging because of stalled leader election.
Change-Id: Ia87f582956e0a61f1d2e1fe792aca1d885f20af3
Signed-off-by: Jeff Darcy <jdarcy@redhat.com>
-rw-r--r-- | xlators/cluster/nsr-server/src/etcd-sim.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/xlators/cluster/nsr-server/src/etcd-sim.c b/xlators/cluster/nsr-server/src/etcd-sim.c index 5c5cdcec0..6ce3de689 100644 --- a/xlators/cluster/nsr-server/src/etcd-sim.c +++ b/xlators/cluster/nsr-server/src/etcd-sim.c @@ -156,11 +156,12 @@ etcd_set (etcd_session this, char *key, char *value, delta = difftime(new, old); // check if the present key is expired if ( (!ttl) || ((delta >= 0) && (delta < ttl))) { - // present key not expired. In case of precondition, - // check if it matches. If not return with error - // In case of no precond, return error since - // present key not yet expired. - if ((!precond) || (strcmp(precond, s))) { + /* + * The only case in which we should fail here + * is if a precondition was specified and does + * not match the current (non-expired) value. + */ + if (precond && strcmp(precond, s)) { free(str); lockf(sim->fd, F_ULOCK, 0 ); return ETCD_WTF; |