summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/tools/test/fmt.rs1
-rw-r--r--cli/tsc/99_main_compiler.js2
-rw-r--r--cli/tsc/dts/lib.deno.unstable.d.ts20
-rw-r--r--ext/fs/30_fs.js12
-rw-r--r--ext/fs/lib.rs2
-rw-r--r--ext/fs/ops.rs24
-rw-r--r--runtime/js/90_deno_ns.js4
-rw-r--r--runtime/js/99_main.js4
-rw-r--r--tests/integration/js_unit_tests.rs1
-rw-r--r--tests/specs/future/runtime_api/main.js2
-rw-r--r--tests/specs/future/runtime_api/main.out2
-rw-r--r--tests/unit/flock_test.ts197
12 files changed, 0 insertions, 271 deletions
diff --git a/cli/tools/test/fmt.rs b/cli/tools/test/fmt.rs
index e1e7e1fba..0cdb3f05a 100644
--- a/cli/tools/test/fmt.rs
+++ b/cli/tools/test/fmt.rs
@@ -320,7 +320,6 @@ pub const OP_DETAILS: phf::Map<&'static str, [&'static str; 2]> = phf_map! {
"op_fs_events_poll" => ["get the next file system event", "breaking out of a for await loop looping over `Deno.FsEvents`"],
"op_fs_fdatasync_async" => ["flush pending data operations for a file to disk", "awaiting the result of a `Deno.fdatasync` or `Deno.FsFile.syncData` call"],
"op_fs_file_stat_async" => ["get file metadata", "awaiting the result of a `Deno.fstat` or `Deno.FsFile.stat` call"],
- "op_fs_flock_async_unstable" => ["lock a file", "awaiting the result of a `Deno.flock` call"],
"op_fs_flock_async" => ["lock a file", "awaiting the result of a `Deno.FsFile.lock` call"],
"op_fs_fsync_async" => ["flush pending data operations for a file to disk", "awaiting the result of a `Deno.fsync` or `Deno.FsFile.sync` call"],
"op_fs_ftruncate_async" => ["truncate a file", "awaiting the result of a `Deno.ftruncate` or `Deno.FsFile.truncate` call"],
diff --git a/cli/tsc/99_main_compiler.js b/cli/tsc/99_main_compiler.js
index a0bce0133..a6ec59125 100644
--- a/cli/tsc/99_main_compiler.js
+++ b/cli/tsc/99_main_compiler.js
@@ -46,8 +46,6 @@ delete Object.prototype.__proto__;
"UnixListenOptions",
"createHttpClient",
"dlopen",
- "flock",
- "flockSync",
"funlock",
"funlockSync",
"listen",
diff --git a/cli/tsc/dts/lib.deno.unstable.d.ts b/cli/tsc/dts/lib.deno.unstable.d.ts
index 747ce5a7f..64ee74b84 100644
--- a/cli/tsc/dts/lib.deno.unstable.d.ts
+++ b/cli/tsc/dts/lib.deno.unstable.d.ts
@@ -1218,26 +1218,6 @@ declare namespace Deno {
/** **UNSTABLE**: New API, yet to be vetted.
*
- * Acquire an advisory file-system lock for the provided file.
- *
- * @param [exclusive=false]
- * @category File System
- * @experimental
- */
- export function flock(rid: number, exclusive?: boolean): Promise<void>;
-
- /** **UNSTABLE**: New API, yet to be vetted.
- *
- * Acquire an advisory file-system lock synchronously for the provided file.
- *
- * @param [exclusive=false]
- * @category File System
- * @experimental
- */
- export function flockSync(rid: number, exclusive?: boolean): void;
-
- /** **UNSTABLE**: New API, yet to be vetted.
- *
* Release an advisory file-system lock for the provided file.
*
* @category File System
diff --git a/ext/fs/30_fs.js b/ext/fs/30_fs.js
index 6c09ae97a..b95fe623a 100644
--- a/ext/fs/30_fs.js
+++ b/ext/fs/30_fs.js
@@ -20,9 +20,7 @@ import {
op_fs_file_stat_async,
op_fs_file_stat_sync,
op_fs_flock_async,
- op_fs_flock_async_unstable,
op_fs_flock_sync,
- op_fs_flock_sync_unstable,
op_fs_fsync_async,
op_fs_fsync_sync,
op_fs_ftruncate_async,
@@ -554,14 +552,6 @@ async function fsync(rid) {
await op_fs_fsync_async(rid);
}
-function flockSync(rid, exclusive) {
- op_fs_flock_sync_unstable(rid, exclusive === true);
-}
-
-async function flock(rid, exclusive) {
- await op_fs_flock_async_unstable(rid, exclusive === true);
-}
-
function funlockSync(rid) {
op_fs_funlock_sync_unstable(rid);
}
@@ -977,8 +967,6 @@ export {
fdatasync,
fdatasyncSync,
File,
- flock,
- flockSync,
FsFile,
fstat,
fstatSync,
diff --git a/ext/fs/lib.rs b/ext/fs/lib.rs
index 8eb6f2764..be43c81d9 100644
--- a/ext/fs/lib.rs
+++ b/ext/fs/lib.rs
@@ -235,8 +235,6 @@ deno_core::extension!(deno_fs,
op_fs_fsync_async,
op_fs_file_stat_sync,
op_fs_file_stat_async,
- op_fs_flock_sync_unstable,
- op_fs_flock_async_unstable,
op_fs_funlock_sync_unstable,
op_fs_funlock_async_unstable,
op_fs_flock_async,
diff --git a/ext/fs/ops.rs b/ext/fs/ops.rs
index e8a074be5..7d28b56b0 100644
--- a/ext/fs/ops.rs
+++ b/ext/fs/ops.rs
@@ -1494,30 +1494,6 @@ pub async fn op_fs_file_stat_async(
}
#[op2(fast)]
-pub fn op_fs_flock_sync_unstable(
- state: &mut OpState,
- #[smi] rid: ResourceId,
- exclusive: bool,
-) -> Result<(), AnyError> {
- check_unstable(state, "Deno.flockSync");
- let file = FileResource::get_file(state, rid)?;
- file.lock_sync(exclusive)?;
- Ok(())
-}
-
-#[op2(async)]
-pub async fn op_fs_flock_async_unstable(
- state: Rc<RefCell<OpState>>,
- #[smi] rid: ResourceId,
- exclusive: bool,
-) -> Result<(), AnyError> {
- check_unstable(&state.borrow(), "Deno.flock");
- let file = FileResource::get_file(&state.borrow(), rid)?;
- file.lock_async(exclusive).await?;
- Ok(())
-}
-
-#[op2(fast)]
pub fn op_fs_funlock_sync_unstable(
state: &mut OpState,
#[smi] rid: ResourceId,
diff --git a/runtime/js/90_deno_ns.js b/runtime/js/90_deno_ns.js
index 0fb9273bc..7c805e647 100644
--- a/runtime/js/90_deno_ns.js
+++ b/runtime/js/90_deno_ns.js
@@ -251,8 +251,6 @@ denoNsUnstableById[unstableIds.ffi] = {
};
denoNsUnstableById[unstableIds.fs] = {
- flock: fs.flock,
- flockSync: fs.flockSync,
funlock: fs.funlock,
funlockSync: fs.funlockSync,
umask: fs.umask,
@@ -301,8 +299,6 @@ const denoNsUnstable = {
UnsafePointerView: ffi.UnsafePointerView,
UnsafeFnPointer: ffi.UnsafeFnPointer,
UnsafeWindowSurface: webgpuSurface.UnsafeWindowSurface,
- flock: fs.flock,
- flockSync: fs.flockSync,
funlock: fs.funlock,
funlockSync: fs.funlockSync,
openKv: kv.openKv,
diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js
index e0fb86a3f..764a7a23e 100644
--- a/runtime/js/99_main.js
+++ b/runtime/js/99_main.js
@@ -820,8 +820,6 @@ function bootstrapMainRuntime(runtimeOptions, warmup = false) {
delete Deno.fstatSync;
delete Deno.ftruncate;
delete Deno.ftruncateSync;
- delete Deno.flock;
- delete Deno.flockSync;
delete Deno.FsFile.prototype.rid;
delete Deno.funlock;
delete Deno.funlockSync;
@@ -1000,8 +998,6 @@ function bootstrapWorkerRuntime(
delete Deno.fstatSync;
delete Deno.ftruncate;
delete Deno.ftruncateSync;
- delete Deno.flock;
- delete Deno.flockSync;
delete Deno.FsFile.prototype.rid;
delete Deno.funlock;
delete Deno.funlockSync;
diff --git a/tests/integration/js_unit_tests.rs b/tests/integration/js_unit_tests.rs
index 9c4ac0e52..9f1ee7394 100644
--- a/tests/integration/js_unit_tests.rs
+++ b/tests/integration/js_unit_tests.rs
@@ -38,7 +38,6 @@ util::unit_test_factory!(
file_test,
filereader_test,
files_test,
- flock_test,
fs_events_test,
get_random_values_test,
globals_test,
diff --git a/tests/specs/future/runtime_api/main.js b/tests/specs/future/runtime_api/main.js
index 0c03dab33..a541c097f 100644
--- a/tests/specs/future/runtime_api/main.js
+++ b/tests/specs/future/runtime_api/main.js
@@ -6,8 +6,6 @@ console.log("Deno.fstat is", Deno.fstat);
console.log("Deno.fstatSync is", Deno.fstatSync);
console.log("Deno.ftruncate is", Deno.ftruncate);
console.log("Deno.ftruncateSync is", Deno.ftruncateSync);
-console.log("Deno.flock is", Deno.flock);
-console.log("Deno.flockSync is", Deno.flockSync);
console.log(
"Deno.FsFile.prototype.rid is",
Deno.openSync(import.meta.filename).rid,
diff --git a/tests/specs/future/runtime_api/main.out b/tests/specs/future/runtime_api/main.out
index f04a0b4e9..637c60dfc 100644
--- a/tests/specs/future/runtime_api/main.out
+++ b/tests/specs/future/runtime_api/main.out
@@ -6,8 +6,6 @@ Deno.fstat is undefined
Deno.fstatSync is undefined
Deno.ftruncate is undefined
Deno.ftruncateSync is undefined
-Deno.flock is undefined
-Deno.flockSync is undefined
Deno.FsFile.prototype.rid is undefined
Deno.funlock is undefined
Deno.funlockSync is undefined
diff --git a/tests/unit/flock_test.ts b/tests/unit/flock_test.ts
deleted file mode 100644
index f2a75e5d4..000000000
--- a/tests/unit/flock_test.ts
+++ /dev/null
@@ -1,197 +0,0 @@
-// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
-import { assertEquals, DENO_FUTURE } from "./test_util.ts";
-
-Deno.test(
- { ignore: DENO_FUTURE, permissions: { read: true, run: true, hrtime: true } },
- async function flockFileSync() {
- await runFlockTests({ sync: true });
- },
-);
-
-Deno.test(
- { ignore: DENO_FUTURE, permissions: { read: true, run: true, hrtime: true } },
- async function flockFileAsync() {
- await runFlockTests({ sync: false });
- },
-);
-
-async function runFlockTests(opts: { sync: boolean }) {
- assertEquals(
- await checkFirstBlocksSecond({
- firstExclusive: true,
- secondExclusive: false,
- sync: opts.sync,
- }),
- true,
- "exclusive blocks shared",
- );
- assertEquals(
- await checkFirstBlocksSecond({
- firstExclusive: false,
- secondExclusive: true,
- sync: opts.sync,
- }),
- true,
- "shared blocks exclusive",
- );
- assertEquals(
- await checkFirstBlocksSecond({
- firstExclusive: true,
- secondExclusive: true,
- sync: opts.sync,
- }),
- true,
- "exclusive blocks exclusive",
- );
- assertEquals(
- await checkFirstBlocksSecond({
- firstExclusive: false,
- secondExclusive: false,
- sync: opts.sync,
- // need to wait for both to enter the lock to prevent the case where the
- // first process enters and exits the lock before the second even enters
- waitBothEnteredLock: true,
- }),
- false,
- "shared does not block shared",
- );
-}
-
-async function checkFirstBlocksSecond(opts: {
- firstExclusive: boolean;
- secondExclusive: boolean;
- sync: boolean;
- waitBothEnteredLock?: boolean;
-}) {
- const firstProcess = runFlockTestProcess({
- exclusive: opts.firstExclusive,
- sync: opts.sync,
- });
- const secondProcess = runFlockTestProcess({
- exclusive: opts.secondExclusive,
- sync: opts.sync,
- });
- try {
- const sleep = (time: number) => new Promise((r) => setTimeout(r, time));
-
- await Promise.all([
- firstProcess.waitStartup(),
- secondProcess.waitStartup(),
- ]);
-
- await firstProcess.enterLock();
- await firstProcess.waitEnterLock();
-
- await secondProcess.enterLock();
- await sleep(100);
-
- if (!opts.waitBothEnteredLock) {
- await firstProcess.exitLock();
- }
-
- await secondProcess.waitEnterLock();
-
- if (opts.waitBothEnteredLock) {
- await firstProcess.exitLock();
- }
-
- await secondProcess.exitLock();
-
- // collect the final output
- const firstPsTimes = await firstProcess.getTimes();
- const secondPsTimes = await secondProcess.getTimes();
- return firstPsTimes.exitTime < secondPsTimes.enterTime;
- } finally {
- await firstProcess.close();
- await secondProcess.close();
- }
-}
-
-function runFlockTestProcess(opts: { exclusive: boolean; sync: boolean }) {
- const path = "tests/testdata/assets/lock_target.txt";
- const scriptText = `
- const { rid } = Deno.openSync("${path}");
-
- // ready signal
- Deno.stdout.writeSync(new Uint8Array(1));
- // wait for enter lock signal
- Deno.stdin.readSync(new Uint8Array(1));
-
- // entering signal
- Deno.stdout.writeSync(new Uint8Array(1));
- // lock and record the entry time
- ${
- opts.sync
- ? `Deno.flockSync(rid, ${opts.exclusive ? "true" : "false"});`
- : `await Deno.flock(rid, ${opts.exclusive ? "true" : "false"});`
- }
- const enterTime = new Date().getTime();
- // entered signal
- Deno.stdout.writeSync(new Uint8Array(1));
-
- // wait for exit lock signal
- Deno.stdin.readSync(new Uint8Array(1));
-
- // record the exit time and wait a little bit before releasing
- // the lock so that the enter time of the next process doesn't
- // occur at the same time as this exit time
- const exitTime = new Date().getTime();
- await new Promise(resolve => setTimeout(resolve, 100));
-
- // release the lock
- ${opts.sync ? "Deno.funlockSync(rid);" : "await Deno.funlock(rid);"}
-
- // exited signal
- Deno.stdout.writeSync(new Uint8Array(1));
-
- // output the enter and exit time
- console.log(JSON.stringify({ enterTime, exitTime }));
-`;
-
- const process = new Deno.Command(Deno.execPath(), {
- args: ["eval", "--unstable", scriptText],
- stdin: "piped",
- stdout: "piped",
- stderr: "null",
- }).spawn();
-
- const waitSignal = async () => {
- const reader = process.stdout.getReader({ mode: "byob" });
- await reader.read(new Uint8Array(1));
- reader.releaseLock();
- };
- const signal = async () => {
- const writer = process.stdin.getWriter();
- await writer.write(new Uint8Array(1));
- writer.releaseLock();
- };
-
- return {
- async waitStartup() {
- await waitSignal();
- },
- async enterLock() {
- await signal();
- await waitSignal(); // entering signal
- },
- async waitEnterLock() {
- await waitSignal();
- },
- async exitLock() {
- await signal();
- await waitSignal();
- },
- getTimes: async () => {
- const { stdout } = await process.output();
- const text = new TextDecoder().decode(stdout);
- return JSON.parse(text) as {
- enterTime: number;
- exitTime: number;
- };
- },
- close: async () => {
- await process.status;
- await process.stdin.close();
- },
- };
-}