Browse Source

fix locking of files

Anthony Bretaudeau 7 years ago
parent
commit
ab6650ad31

+ 5 - 1
tripal/includes/tripal.upload.inc

@@ -118,6 +118,7 @@ function tripal_file_upload_merge($filename, $type, $user_dir) {
       $status = 'failed';
       $message = 'Cannot open merged file: ' . $merge_file . '.';
     }
+    flock($merge_fh, LOCK_UN);
     fclose($merge_fh);
   }
 
@@ -234,6 +235,7 @@ function tripal_file_upload_put($filename, $chunk, $user_dir) {
       while ($data = fread($putdata, 1024)) {
         fwrite($fh, $data);
       }
+      flock($fh, LOCK_UN);
       fclose($fh);
     }
   }
@@ -271,6 +273,7 @@ function tripal_file_upload_read_log($temp_dir) {
       }
       $log = unserialize($contents);
     }
+    flock($fh, LOCK_UN);
     fclose($fh);
   }
   if (!is_array($log)) {
@@ -309,5 +312,6 @@ function tripal_file_upoad_write_log($temp_dir, $log) {
   if ($fh and flock($fh, LOCK_EX)) {
     fwrite($fh, serialize($log));
   }
+  flock($fh, LOCK_UN);
   fclose($fh);
-}
+}

+ 0 - 1
tripal_chado/includes/tripal_chado.field_storage.inc

@@ -1328,4 +1328,3 @@ function tripal_chado_field_storage_bundle_mapping_form_submit($form,
   }
 }
 
-

+ 1 - 1
tripal_ws/includes/TripalWebService.inc

@@ -224,7 +224,7 @@ class TripalWebService {
     $cfh = fopen($context_file_path, "w");
     if (flock($cfh, LOCK_EX)) {
       fwrite($cfh, json_encode($context));
-      flock($context_file_path, LOCK_UN);
+      flock($cfh, LOCK_UN);
       fclose($cfh);
     }
     else {