Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Unified Diff: pkg/barback/lib/src/utils.dart

Issue 28733009: Make sure barback's FilePool doesn't take up *all* the available FDs. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« pkg/barback/lib/src/file_pool.dart ('K') | « pkg/barback/lib/src/file_pool.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/barback/lib/src/utils.dart
diff --git a/pkg/barback/lib/src/utils.dart b/pkg/barback/lib/src/utils.dart
index 22203b4c89dc52a9580f600e9cb636cbc46a98f0..ef6a783053871d8b1c3f30f159f0f8358b78287d 100644
--- a/pkg/barback/lib/src/utils.dart
+++ b/pkg/barback/lib/src/utils.dart
@@ -5,6 +5,7 @@
library barback.utils;
import 'dart:async';
+import 'dart:io';
/// A pair of values.
class Pair<E, F> {
@@ -195,3 +196,23 @@ Stream futureStream(Future<Stream> future) {
});
return controller.stream;
}
+
+// TODO(nweiz): Use a built-in function when issue 14244 is fixed.
+int get maxFileDescriptors {
+ if (_maxFileDescriptors != null) return _maxFileDescriptors;
+
+ // Running "sh -c ulimit -n" via the command line always reports "unlimited",
+ // even when that's clearly false. Instead we fall back on OS-based
+ // heuristics.
+ if (Platform.isWindows) {
+ _maxFileDescriptors = 512;
+ return _maxFileDescriptors;
+ } else if (Platform.isMacOS) {
+ _maxFileDescriptors = 16348;
+ return _maxFileDescriptors;
+ } else {
+ _maxFileDescriptors = 256;
+ return _maxFileDescriptors;
+ }
+}
+int _maxFileDescriptors;
« pkg/barback/lib/src/file_pool.dart ('K') | « pkg/barback/lib/src/file_pool.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698