summaryrefslogtreecommitdiffstats
path: root/sbin/hastd
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2012-02-11 16:41:52 +0000
committerpjd <pjd@FreeBSD.org>2012-02-11 16:41:52 +0000
commit3e86e21237c556aca42212d457e89b7ca8c54064 (patch)
tree706eda62b6195518fdce11a7e922884c6ec79435 /sbin/hastd
parent80e768e1e7361286ba663754d0865ac1273e5a75 (diff)
downloadFreeBSD-src-3e86e21237c556aca42212d457e89b7ca8c54064.zip
FreeBSD-src-3e86e21237c556aca42212d457e89b7ca8c54064.tar.gz
Nice range comparison.
MFC after: 3 days
Diffstat (limited to 'sbin/hastd')
-rw-r--r--sbin/hastd/rangelock.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/sbin/hastd/rangelock.c b/sbin/hastd/rangelock.c
index 5ff1f19..e14c5b8 100644
--- a/sbin/hastd/rangelock.c
+++ b/sbin/hastd/rangelock.c
@@ -128,15 +128,13 @@ bool
rangelock_islocked(struct rangelocks *rls, off_t offset, off_t length)
{
struct rlock *rl;
+ off_t end;
PJDLOG_ASSERT(rls->rls_magic == RANGELOCKS_MAGIC);
+ end = offset + length;
TAILQ_FOREACH(rl, &rls->rls_locks, rl_next) {
- if (rl->rl_start >= offset && rl->rl_start < offset + length)
- break;
- else if (rl->rl_end > offset && rl->rl_end <= offset + length)
- break;
- else if (rl->rl_start < offset && rl->rl_end > offset + length)
+ if (rl->rl_start < end && rl->rl_end > offset)
break;
}
return (rl != NULL);
OpenPOWER on IntegriCloud