mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1011158
- Tighten the lock around OS.File |kill| operation. r=froydnj
This commit is contained in:
parent
2fd48f767d
commit
e80860fc4d
@ -192,12 +192,20 @@ let Scheduler = {
|
||||
shutdown: false,
|
||||
|
||||
/**
|
||||
* A promise resolved once all operations are complete.
|
||||
* A promise resolved once all currently pending operations are complete.
|
||||
*
|
||||
* This promise is never rejected and the result is always undefined.
|
||||
*/
|
||||
queue: Promise.resolve(),
|
||||
|
||||
/**
|
||||
* A promise resolved once all currently pending `kill` operations
|
||||
* are complete.
|
||||
*
|
||||
* This promise is never rejected and the result is always undefined.
|
||||
*/
|
||||
_killQueue: Promise.resolve(),
|
||||
|
||||
/**
|
||||
* Miscellaneous debugging information
|
||||
*/
|
||||
@ -286,7 +294,14 @@ let Scheduler = {
|
||||
* through some other mean.
|
||||
*/
|
||||
kill: function({shutdown, reset}) {
|
||||
return Task.spawn(function*() {
|
||||
// Grab the kill queue to make sure that we
|
||||
// cannot be interrupted by another call to `kill`.
|
||||
let killQueue = this._killQueue;
|
||||
return this._killQueue = Task.spawn(function*() {
|
||||
|
||||
yield killQueue;
|
||||
// From this point, and until the end of the Task, we are the
|
||||
// only call to `kill`, regardless of any `yield`.
|
||||
|
||||
yield this.queue;
|
||||
|
||||
|
@ -1,20 +1,18 @@
|
||||
Components.utils.import("resource://gre/modules/Services.jsm", this);
|
||||
Components.utils.import("resource://gre/modules/Promise.jsm", this);
|
||||
Components.utils.import("resource://gre/modules/Task.jsm", this);
|
||||
Components.utils.import("resource://gre/modules/osfile.jsm", this);
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
let Path = OS.Constants.Path;
|
||||
|
||||
add_task(function init() {
|
||||
add_task(function* init() {
|
||||
do_get_profile();
|
||||
});
|
||||
|
||||
add_task(function reset_before_launching() {
|
||||
add_task(function* reset_before_launching() {
|
||||
do_print("Reset without launching OS.File, it shouldn't break");
|
||||
yield OS.File.resetWorker();
|
||||
});
|
||||
|
||||
add_task(function transparent_reset() {
|
||||
add_task(function* transparent_reset() {
|
||||
for (let i = 1; i < 3; ++i) {
|
||||
do_print("Do stome stuff before and after " + i + " reset(s), " +
|
||||
"it shouldn't break");
|
||||
@ -30,7 +28,7 @@ add_task(function transparent_reset() {
|
||||
}
|
||||
});
|
||||
|
||||
add_task(function file_open_cannot_reset() {
|
||||
add_task(function* file_open_cannot_reset() {
|
||||
let TEST_FILE = OS.Path.join(Path.profileDir, "tmp-" + Math.random());
|
||||
do_print("Leaking file descriptor " + TEST_FILE + ", we shouldn't be able to reset");
|
||||
let openedFile = yield OS.File.open(TEST_FILE, { create: true} );
|
||||
@ -47,7 +45,7 @@ add_task(function file_open_cannot_reset() {
|
||||
yield OS.File.resetWorker();
|
||||
});
|
||||
|
||||
add_task(function dir_open_cannot_reset() {
|
||||
add_task(function* dir_open_cannot_reset() {
|
||||
let TEST_DIR = yield OS.File.getCurrentDirectory();
|
||||
do_print("Leaking directory " + TEST_DIR + ", we shouldn't be able to reset");
|
||||
let iterator = new OS.File.DirectoryIterator(TEST_DIR);
|
||||
@ -64,7 +62,24 @@ add_task(function dir_open_cannot_reset() {
|
||||
yield OS.File.resetWorker();
|
||||
});
|
||||
|
||||
add_task(function finish_with_a_reset() {
|
||||
add_task(function* race_against_itself() {
|
||||
do_print("Attempt to get resetWorker() to race against itself");
|
||||
// Arbitrary operation, just to wake up the worker
|
||||
try {
|
||||
yield OS.File.read("/foo");
|
||||
} catch (ex) {
|
||||
}
|
||||
|
||||
let all = [];
|
||||
for (let i = 0; i < 100; ++i) {
|
||||
all.push(OS.File.resetWorker());
|
||||
}
|
||||
|
||||
yield Promise.all(all);
|
||||
});
|
||||
|
||||
|
||||
add_task(function* finish_with_a_reset() {
|
||||
do_print("Reset without waiting for the result");
|
||||
// Arbitrary operation, just to wake up the worker
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user