diff --git a/src/xpdev/filewrap.c b/src/xpdev/filewrap.c
index 3cd9ba83406211b050e8313e9ce80f41512a1409..da2c5713e95b7591e5b3066e1124712789f0887e 100644
--- a/src/xpdev/filewrap.c
+++ b/src/xpdev/filewrap.c
@@ -259,7 +259,7 @@ int xp_lockfile(int file, off_t offset, off_t size, bool block)
 		(void)lseek(file, offset, SEEK_SET);
 	do {
 		i = _locking(file, block ? LK_LOCK : LK_NBLCK, (long)size);
-	} while(block && i != 0 && errno = EDEADLOCK);
+	} while(block && i != 0 && errno == EDEADLOCK);
 	if(offset!=pos)
 		(void)lseek(file, pos, SEEK_SET);
 	return(i);