diff --git a/inc/io.php b/inc/io.php
index a44e498a21cfe90f96c54d5a039237ceae247683..ea20502bb0f59c7869ec52e26b44d10cabb2f6c6 100644
--- a/inc/io.php
+++ b/inc/io.php
@@ -181,7 +181,11 @@ function io_lock($file){
     //waited longer than 3 seconds? -> stale lock
     if ((time() - $timeStart) > 3) break;
     $locked = @mkdir($lockDir, $conf['dmode']);
-    if($locked && $conf['dperm']) chmod($lockDir, $conf['dperm']);
+    if($locked){
+      if($conf['dperm']) chmod($lockDir, $conf['dperm']);
+      break;
+    }
+    usleep(50);
   } while ($locked === false);
 }