Closed
Bug 106949
Opened 24 years ago
Closed 14 years ago
Bad use of nsIFile in component manager [FIX]
Categories
(Core :: XPCOM, defect, P1)
Core
XPCOM
Tracking
()
RESOLVED
WORKSFORME
Future
People
(Reporter: ccarlen, Assigned: pete)
Details
Attachments
(5 files)
|
1.76 KB,
patch
|
Details | Diff | Splinter Review | |
|
2.07 KB,
patch
|
jband_mozilla
:
superreview+
|
Details | Diff | Splinter Review |
|
2.87 KB,
patch
|
ccarlen
:
review+
|
Details | Diff | Splinter Review |
|
2.80 KB,
patch
|
ccarlen
:
review+
jband_mozilla
:
superreview+
|
Details | Diff | Splinter Review |
|
2.02 KB,
patch
|
Details | Diff | Splinter Review |
This bit:
http://lxr.mozilla.org/mozilla/source/xpcom/components/nsComponentManager.cpp#2247
is evil. mComponentsOffset is the length of the path of the components dir.
Because this code is getting the full path and then advancing the pointer past
the parent dir portion, it requires that the path does not end in a separator.
This shouldn't be required of nsIFile. If it is more efficient, or the norm on
the OS, for directory paths to end in separators, the implementation should be
able to do that. Code which depends on this detail, such as this, needs to be
changed.
| Reporter | ||
Comment 1•24 years ago
|
||
Not only that, this code is slow. It seems that what it's after is the leaf name
of the file. For that, there's GetLeaf().
Updated•24 years ago
|
Target Milestone: --- → mozilla0.9.7
Updated•24 years ago
|
Keywords: helpwanted
Target Milestone: mozilla0.9.7 → Future
| Assignee | ||
Comment 2•24 years ago
|
||
Fix forthcoming
--pete
| Assignee | ||
Comment 3•24 years ago
|
||
| Assignee | ||
Comment 4•24 years ago
|
||
Doug or Conrad, assign this bug to me. Someone give me an r= and i'll work on an sr=
--pete
Assignee: dougt → petejc
| Assignee | ||
Updated•24 years ago
|
Status: NEW → ASSIGNED
Summary: Bad use of nsIFile in component manager → Bad use of nsIFile in component manager [FIX]
| Assignee | ||
Updated•24 years ago
|
Priority: -- → P1
Target Milestone: Future → mozilla0.9.7
| Reporter | ||
Comment 5•24 years ago
|
||
Comment on attachment 60898 [details] [diff] [review]
fix, need review
>@@ -710,8 +710,6 @@
> if (!componentDescriptor)
> return NS_ERROR_NULL_POINTER;
>
>- mComponentsOffset = strlen(componentDescriptor);
>-
Once this is taken out, componentDescriptor is not used and should come out,
along with the calls that use it.
> if (componentDescriptor)
> nsMemory::Free(componentDescriptor);
>
>@@ -2110,9 +2108,11 @@
> if (NS_FAILED(rv))
> return rv;
>
There's a call to GetPath() in here that can go now.
>- char* relativeLocation = persistentDescriptor + mComponentsOffset + 1;
>+ nsXPIDLCString relativeLocation;
>+ if (NS_FAILED(rv = aSpec->GetLeafName(getter_Copies(relativeLocation))))
>+ return rv;
>
>- rv = MakeRegistryName(relativeLocation, XPCOM_RELCOMPONENT_PREFIX,
>+ rv = MakeRegistryName(relativeLocation.get(), XPCOM_RELCOMPONENT_PREFIX,
> aRegistryName);
| Assignee | ||
Comment 6•24 years ago
|
||
Comment 7•24 years ago
|
||
Comment on attachment 60951 [details] [diff] [review]
revised patch
sr=jband
Looks reasonable to me. I'm sure Conrad will tell you if you slipped up on some
detail I don't see.
Attachment #60951 -
Flags: superreview+
| Assignee | ||
Comment 8•24 years ago
|
||
| Assignee | ||
Comment 9•24 years ago
|
||
patch 60969 is the same except i changed char *persistentDescriptor to
nsXPIDLCString and
removed call to ::Free since nsXPIDLCString class has it's own destructor.
So either patch is good for review. patch 60969 is my preference.
Reguards performance, this patch doesn't really make any difference at least on
unix.
Using time, here are some fuzzy random results. These numbers were generated by
xpcshell
running an external js script the prints 'Hello World'. With and without the
generation of
component.reg.
(Spacing may be horked below)
patch original
TRY #1 TRY #1
----------------- -----------------
no components.reg no components.reg
real 0m6.233s real 0m6.039s
user 0m5.565s user 0m5.569s
sys 0m0.427s sys 0m0.403s
real 0m0.808s real 0m0.809s
user 0m0.631s user 0m0.581s
sys 0m0.178s sys 0m0.228s
----------------- -----------------
TRY #2 TRY #2
----------------- -----------------
no components.reg no components.reg
real 0m6.161s real 0m6.051s
user 0m5.574s user 0m5.534s
sys 0m0.429s sys 0m0.439s
real 0m0.812s real 0m0.813s
user 0m0.610s user 0m0.644s
sys 0m0.203s sys 0m0.169s
----------------- -----------------
| Reporter | ||
Comment 10•24 years ago
|
||
Comment on attachment 60969 [details] [diff] [review]
changed persistentDescriptor over to nsXPIDLCString
I like this patch r=ccarlen.
Here's some nits you can take or leave:
(1) Since persistentDescriptor is only used within that else block, I'd declare
the variable within that scope.
(2) I'd rename persistentDescriptor -> absoluteLocation. Calling it
"persistentDescriptor" is odd since it didn't come from
GetPersistentDescriptor().
As far as the performance, I didn't think this would bring noticable
improvement - though it may on Mac because GetPath() is very expensive there.
It was mainly this bit:
- char* relativeLocation = persistentDescriptor + mComponentsOffset + 1;
which assumes (requires) that paths to a directory don't end in directory
separator char.
Attachment #60969 -
Flags: review+
| Assignee | ||
Comment 11•24 years ago
|
||
| Reporter | ||
Comment 12•24 years ago
|
||
Comment on attachment 61023 [details] [diff] [review]
renamed var and moved into scope. removed unused GetPath accessor in if block
r=ccarlen
Attachment #61023 -
Flags: review+
| Assignee | ||
Comment 13•24 years ago
|
||
jband, i'm gonna take your sr= for the latest patch, ok.
I'll check this in as soon as the tree reopens today.
Thanks
--pete
Comment 14•24 years ago
|
||
Comment on attachment 61023 [details] [diff] [review]
renamed var and moved into scope. removed unused GetPath accessor in if block
sr=jband
Attachment #61023 -
Flags: superreview+
| Assignee | ||
Comment 15•24 years ago
|
||
Checked in marking FIXED.
Thanks guys.
--pete
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Comment 16•24 years ago
|
||
I suggest that we back this out.
This causes http://bugscape.netscape.com/show_bug.cgi?id=11374
That bug is about the NS spell checker not working.
The general problem is that nsNativeComponentLoader::RegisterComponentsInDir
goes down into subdirectories. The old code here handles that and returned a
substring that might not be the same as the string returned when only asking for
the leaf node.
Since this fix changes the behavior of the code (who knew?) and does not
actually fix anything that *needs* to be fixed. I think the only thing to do is
back it out immediately until a better fix is suggested.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Comment 17•24 years ago
|
||
cvs commands to backout patch 61023
cvs update -j1.71 -j1.70 mozilla/xpcom/components/nsComponentManager.h
cvs update -j1.180 -j1.179 mozilla/xpcom/components/nsComponentManager.cpp
Comment 18•24 years ago
|
||
a=brendan@mozilla.org on behalf of drivers for back-out.
/be
Comment 19•24 years ago
|
||
I backed out patch 61023
| Assignee | ||
Comment 21•24 years ago
|
||
| Assignee | ||
Comment 22•24 years ago
|
||
Hey guys, have a look at patch 62297.
This fixes the problem of components residing in subdirs in the components dir.
Tested and works great.
There seems to be no need at all to register based on relative location.
So that block is now gone.
Please review.
Thanks
--pete
| Reporter | ||
Comment 23•24 years ago
|
||
Relative paths are a good thing. Absolute paths become invalid if somebody moves
their installation from one place to another. On some platforms ;-) people do
this all the time. I think we should leave it as-is until we have the relative
path stuff I've aways wanted on nsIFile. Sorry I filed this - I just completely
overlooked the nested directory case :-/
| Assignee | ||
Comment 24•24 years ago
|
||
Gonna future this for now.
--pete
Target Milestone: mozilla0.9.8 → Future
Updated•20 years ago
|
QA Contact: scc → xpcom
Updated•14 years ago
|
Status: REOPENED → RESOLVED
Closed: 24 years ago → 14 years ago
Resolution: --- → WORKSFORME
You need to log in
before you can comment on or make changes to this bug.
Description
•