about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-09-13 22:16:03 -0700
committerbors <bors@rust-lang.org>2013-09-13 22:16:03 -0700
commit4ac10f8f6e8e07c70fadb676170c5402442e2243 (patch)
treefe463d6dc17f47c5b0721fd009faa6bacf38643b /src/libstd
parent52b9688f923f8fb5bd6547bc6f2dd2d340c4ee4d (diff)
parent0af2bd829e6aaab4faf2cc135bd8b01db728417b (diff)
downloadrust-4ac10f8f6e8e07c70fadb676170c5402442e2243.tar.gz
rust-4ac10f8f6e8e07c70fadb676170c5402442e2243.zip
auto merge of #9185 : alexcrichton/rust/less-changing-directories, r=huonw
While usage of change_dir_locked is synchronized against itself, it's not
synchronized against other relative path usage, so I'm of the opinion that it
just really doesn't help in running tests. In order to prevent the problems that
have been cropping up, this completely removes the function.

All existing tests (except one) using it have been moved to run-pass tests where
they get their own process and don't need to be synchronized with anyone else.

There is one now-ignored rustpkg test because when I moved it to a run-pass test
apparently run-pass isn't set up to have 'extern mod rustc' (it ends up having
linkage failures).
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/unstable/mod.rs53
1 files changed, 0 insertions, 53 deletions
diff --git a/src/libstd/unstable/mod.rs b/src/libstd/unstable/mod.rs
index 51de3caf2ae..e16e6384a4f 100644
--- a/src/libstd/unstable/mod.rs
+++ b/src/libstd/unstable/mod.rs
@@ -68,59 +68,6 @@ fn test_run_in_bare_thread_exchange() {
     }
 }
 
-
-/// Changes the current working directory to the specified
-/// path while acquiring a global lock, then calls `action`.
-/// If the change is successful, releases the lock and restores the
-/// CWD to what it was before, returning true.
-/// Returns false if the directory doesn't exist or if the directory change
-/// is otherwise unsuccessful.
-///
-/// This is used by test cases to avoid cwd races.
-///
-/// # Safety Note
-///
-/// This uses a pthread mutex so descheduling in the action callback
-/// can lead to deadlock. Calling change_dir_locked recursively will
-/// also deadlock.
-pub fn change_dir_locked(p: &Path, action: &fn()) -> bool {
-    #[fixed_stack_segment]; #[inline(never)];
-
-    use os;
-    use os::change_dir;
-    use unstable::sync::atomically;
-    use unstable::finally::Finally;
-
-    unsafe {
-        // This is really sketchy. Using a pthread mutex so descheduling
-        // in the `action` callback can cause deadlock. Doing it in
-        // `task::atomically` to try to avoid that, but ... I don't know
-        // this is all bogus.
-        return do atomically {
-            rust_take_change_dir_lock();
-
-            do (||{
-                let old_dir = os::getcwd();
-                if change_dir(p) {
-                    action();
-                    change_dir(&old_dir)
-                }
-                else {
-                    false
-                }
-            }).finally {
-                rust_drop_change_dir_lock();
-            }
-        }
-    }
-
-    extern {
-        fn rust_take_change_dir_lock();
-        fn rust_drop_change_dir_lock();
-    }
-}
-
-
 /// Dynamically inquire about whether we're running under V.
 /// You should usually not use this unless your test definitely
 /// can't run correctly un-altered. Valgrind is there to help