From 6e424478f19c7f3e09fbcda252ce6bb6649b951f Mon Sep 17 00:00:00 2001 From: Aparajita Fishman Date: Wed, 30 Jan 2013 12:46:05 +0800 Subject: [PATCH 1/2] Warn users if the ulimit is too low and tell them what to do. Setting ulimit in narwhal.conf isn't necessary, not all targets need a larger limit. In addition, if the hard limit is 512, it can't be set above that once the terminal session starts. --- AppKit/Jakefile | 6 ++++-- Tools/nib2cib/main.j | 24 ++++++++++++++++++++++++ common.jake | 19 +++++++++++++++++++ narwhal.local.conf | 6 ------ 4 files changed, 47 insertions(+), 8 deletions(-) diff --git a/AppKit/Jakefile b/AppKit/Jakefile index b465b9f15..70db16a3d 100644 --- a/AppKit/Jakefile +++ b/AppKit/Jakefile @@ -1,8 +1,10 @@ require("../common.jake"); -var framework = require("objective-j/jake").framework; -var BundleTask = require("objective-j/jake").BundleTask; +checkUlimit(); + +var framework = require("objective-j/jake").framework, + BundleTask = require("objective-j/jake").BundleTask; $BUILD_PATH = FILE.join($BUILD_DIR, $CONFIGURATION, 'AppKit'); diff --git a/Tools/nib2cib/main.j b/Tools/nib2cib/main.j index 3e5475c9d..e00eae9ae 100644 --- a/Tools/nib2cib/main.j +++ b/Tools/nib2cib/main.j @@ -22,9 +22,33 @@ @import "Nib2Cib.j" +var OS = require("OS"), + stream = require("narwhal/term").stream; + + function main(args) { + checkUlimit(); + var nib2cib = [[Nib2Cib alloc] initWithArgs:args]; [nib2cib run]; } + +function checkUlimit() +{ + var minUlimit = 1024, + p = OS.popen(["ulimit", "-n"]); + + if (p.wait() === 0) + { + var limit = p.stdout.read().split("\n")[0]; + + if (Number(limit) < minUlimit) + { + stream.print("\0red(\0bold(WARNING:\0)\0) nib2cib may need to open more files than this terminal session currently allows (" + limit + "). Add the following line to your login configuration file (.bash_profile, .bashrc, etc.), start a new terminal session, then try again:\n"); + stream.print("ulimit -n " + minUlimit); + OS.exit(1); + } + } +} diff --git a/common.jake b/common.jake index 9eded1280..eb2b2dbdc 100644 --- a/common.jake +++ b/common.jake @@ -540,6 +540,25 @@ global.colorPrint = function(/* String */ message, /* String */ color) stream.print(colorize(message, color)); }; +var minUlimit = 1024; + +global.checkUlimit = function() +{ + var p = OS.popen(["ulimit", "-n"]); + + if (p.wait() === 0) + { + var limit = p.stdout.read().split("\n")[0]; + + if (Number(limit) < minUlimit) + { + stream.print("\0red(\0bold(WARNING:\0)\0) Cappuccino may need to open more files than this terminal session currently allows (" + limit + "). Add the following line to your login configuration file (.bash_profile, .bashrc, etc.), start a new terminal session, then try again:\n"); + stream.print("ulimit -n " + minUlimit); + OS.exit(1); + } + } +} + // built in tasks diff --git a/narwhal.local.conf b/narwhal.local.conf index 235176eab..9fe4e691b 100644 --- a/narwhal.local.conf +++ b/narwhal.local.conf @@ -1,9 +1,3 @@ if [ -z "$NARWHAL_ENGINE" ] && [ -d "$NARWHAL_HOME/packages/narwhal-jsc" ]; then export NARWHAL_ENGINE=jsc fi - -if [ "$NARWHAL_ENGINE" == jsc ] && [ `ulimit -n` -lt 512 ]; then - # JSC and Narwhal together have some trouble closing files, leading to the Cappuccino - # build process crashing with a "popen error (pipe): Too many open files" error. - ulimit -n 512 -fi From eefec02de4bcda8ee0a653ade8ae3a61ee08b830 Mon Sep 17 00:00:00 2001 From: Aparajita Fishman Date: Wed, 30 Jan 2013 18:15:42 +0800 Subject: [PATCH 2/2] Fixed tracking event listener test to actually look for tracking events, fixed some method documentation --- AppKit/CPApplication.j | 20 +++++++++++--------- AppKit/Platform/DOM/CPPlatformWindow+DOM.j | 13 ++++++++----- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/AppKit/CPApplication.j b/AppKit/CPApplication.j index ebf440b6d..cfab103f2 100644 --- a/AppKit/CPApplication.j +++ b/AppKit/CPApplication.j @@ -915,11 +915,12 @@ CPRunContinuesResponse = -1002; /*! Fires a callback function when an event matching a given mask occurs. - @param aCallback - A js function to be fired. - @prarm aMask - An event mask for the next event. - @param anExpiration - The date for which this callback expires (not implemented). + @param aCallback A js function to be fired. + @prarm aMask An event mask for the next event. + @param anExpiration The date for which this callback expires (not implemented). @param inMode (not implemented). - @param shouldDequeue (not implemented). + @param shouldDequeue YES to remove the event from the queue after calling the callback, + NO to deliver it normally. */ - (void)setCallback:(Function)aCallback forNextEventMatchingMask:(unsigned int)aMask untilDate:(CPDate)anExpiration inMode:(CPString)aMode dequeue:(BOOL)shouldDequeue { @@ -930,12 +931,13 @@ CPRunContinuesResponse = -1002; Assigns a target and action for the next event matching a given event mask. The callback method called will be passed the CPEvent when it fires. - @param aTarget - The target object for the callback. - @param aSelector - The selector which should be called on the target object. - @param aMask - The mask for a given event which should trigger the callback. - @param anExpiration - The date for which the callback expires (not implemented). + @param aTarget The target object for the callback. + @param aSelector The selector which should be called on the target object. + @param aMask The mask for a given event which should trigger the callback. + @param anExpiration The date for which the callback expires (not implemented). @param aMode (not implemented). - @param shouldDequeue (not implemented). + @param shouldDequeue YES to remove the event from the queue after calling the callback, + NO to deliver it normally. */ - (void)setTarget:(id)aTarget selector:(SEL)aSelector forNextEventMatchingMask:(unsigned int)aMask untilDate:(CPDate)anExpiration inMode:(CPString)aMode dequeue:(BOOL)shouldDequeue { diff --git a/AppKit/Platform/DOM/CPPlatformWindow+DOM.j b/AppKit/Platform/DOM/CPPlatformWindow+DOM.j index ae91f7f5c..4e6e9e66f 100644 --- a/AppKit/Platform/DOM/CPPlatformWindow+DOM.j +++ b/AppKit/Platform/DOM/CPPlatformWindow+DOM.j @@ -318,7 +318,8 @@ var resizeTimer = nil; // Make sure the pastboard element is blurred. _DOMPasteboardElement.blur(); - // Create a full screen div to protect against iframes and other elements from consuming events during tracking + // Create a full screen div to protect against iframes and other elements + // from consuming events during tracking // FIXME: multiple windows _DOMEventGuard = theDocument.createElement("div"); _DOMEventGuard.style.position = "absolute"; @@ -1275,7 +1276,7 @@ var resizeTimer = nil; _DOMEventMode = YES; _mouseIsDown = YES; - //fake a down and up event so that event tracking mode will work correctly + // Fake a down and up event so that event tracking mode will work correctly [CPApp sendEvent:[CPEvent mouseEventWithType:_mouseDownIsRightClick ? CPRightMouseDown : CPLeftMouseDown location:location modifierFlags:modifierFlags timestamp:timestamp windowNumber:windowNumber context:nil eventNumber:-1 clickCount:CPDOMEventGetClickCount(_lastMouseDown, timestamp, location) pressure:0]]; @@ -1322,13 +1323,15 @@ var resizeTimer = nil; if (StopDOMEventPropagation && (!supportsNativeDragAndDrop || type !== "mousedown" && !isDragging)) CPDOMEventStop(aDOMEvent, self); - // if there are any tracking event listeners then show the event guard so we don't lose events to iframes - // TODO Actually check for tracking event listeners, not just any listener but _CPRunModalLoop. + // If there are any tracking event listeners (listening for CPLeftMouseDraggedMask) + // then show the event guard so we don't lose events to iframes var hasTrackingEventListener = NO; for (var i = 0; i < CPApp._eventListeners.length; i++) { - if (CPApp._eventListeners[i]._callback !== _CPRunModalLoop) + var listener = CPApp._eventListeners[i]; + + if (listener._callback !== _CPRunModalLoop && (listener._mask & CPLeftMouseDraggedMask)) { hasTrackingEventListener = YES; break;