-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[io/mac] Ensure FSEventsWatcher::Node is deleted synchronously with C…
…allback that uses it. This is follow-up to ed82bb6 TEST=tests/standalone/io/file_system_watcher_large_set_test.dart Change-Id: If02c922eafe1371c6e67196158896b9cb786bfd6 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202312 Commit-Queue: Alexander Aprelev <[email protected]> Reviewed-by: Slava Egorov <[email protected]>
- Loading branch information
1 parent
63a7741
commit 05e5427
Showing
7 changed files
with
113 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
tests/standalone/io/file_system_watcher_large_set_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
// VMOptions=--delayed-filewatch-callback --enable-isolate-groups --experimental-enable-isolate-groups-jit | ||
// VMOptions=--delayed-filewatch-callback --no-enable-isolate-groups | ||
|
||
// Verifies that cancelling subscription from inside of the event handler | ||
// works as expected, does not result in crash or hang. | ||
|
||
import "dart:async"; | ||
import "dart:io"; | ||
|
||
import "package:path/path.dart"; | ||
|
||
final completer = Completer<void>(); | ||
late StreamSubscription subscription; | ||
|
||
void handleWatchEvent(event) { | ||
if (event is FileSystemCreateEvent && event.path.endsWith('txt')) { | ||
subscription.cancel(); | ||
completer.complete(); | ||
} | ||
} | ||
|
||
void main() async { | ||
if (!FileSystemEntity.isWatchSupported) return; | ||
final dir = Directory.systemTemp.createTempSync('dart_file_system_watcher'); | ||
final watcher = dir.watch(); | ||
subscription = watcher.listen(handleWatchEvent); | ||
|
||
print('watching ${dir.path}'); | ||
for (int i = 0; i < 1000; i++) { | ||
File(join(dir.path, 'file_$i.txt')).createSync(); | ||
} | ||
await completer.future; | ||
try { | ||
dir.deleteSync(recursive: true); | ||
} catch (_) {} | ||
} |
40 changes: 40 additions & 0 deletions
40
tests/standalone_2/io/file_system_watcher_large_set_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
// VMOptions=--delayed-filewatch-callback --enable-isolate-groups --experimental-enable-isolate-groups-jit | ||
// VMOptions=--delayed-filewatch-callback --no-enable-isolate-groups | ||
|
||
// Verifies that cancelling subscription from inside of the event handler | ||
// works as expected, does not result in crash or hang. | ||
|
||
import "dart:async"; | ||
import "dart:io"; | ||
|
||
import "package:path/path.dart"; | ||
|
||
final completer = Completer<void>(); | ||
var subscription; | ||
|
||
void handleWatchEvent(event) { | ||
if (event is FileSystemCreateEvent && event.path.endsWith('txt')) { | ||
subscription.cancel(); | ||
completer.complete(); | ||
} | ||
} | ||
|
||
void main() async { | ||
if (!FileSystemEntity.isWatchSupported) return; | ||
final dir = Directory.systemTemp.createTempSync('dart_file_system_watcher'); | ||
final watcher = dir.watch(); | ||
subscription = watcher.listen(handleWatchEvent); | ||
|
||
print('watching ${dir.path}'); | ||
for (int i = 0; i < 1000; i++) { | ||
File(join(dir.path, 'file_$i.txt')).createSync(); | ||
} | ||
await completer.future; | ||
try { | ||
dir.deleteSync(recursive: true); | ||
} catch (_) {} | ||
} |