Closed Bug 55065 Opened 25 years ago Closed 24 years ago

cache services in nsHTTPChannel

Categories

(Core :: Networking: HTTP, defect, P3)

x86
Linux
defect

Tracking

()

VERIFIED FIXED
mozilla1.0

People

(Reporter: dougt, Assigned: darin.moz)

Details

There are about 10 calls to NS_WITH_SERVICE some of which can be factored into the http channel's init call. Bounce this back to me if want.
dougt: not sure exactly what you have in mind. Are you suggesting that the results of NS_WITH_SERVICE be "cached" in the http channel as either member variables or static member variables? With that in mind, what is the policy on saving a pointer to an interface returned by NS_WITH_SERVICE? Would the result of NS_WITH_SERVICE ever change throughout the lifetime of a particular mozilla instance? I understand that if I want to cache the result of NS_WITH_SERVICE in a global/static variable that I would have to provide the appropriate thread synchronization code. Are there any other gotchas that I should be aware of if I were to go that route?
yea, NS_WITH_SERVICE's should be avoided when possible (thus caching the result is a fine thing to do). You'd want to cache them as member variables (nsCOMPtrs of course) so that when the channel went away, they'd go away too (automattically). One of the rules of COM (subsequently XPCOM) is that once you have a pointer to something, that pointer is valid until you release it. In short, nothing can change underneath you as long as you hold a ref to it.
->me
Assignee: gagan → darin
Component: Networking → Networking: HTTP
Target Milestone: --- → Future
Target Milestone: Future → mozilla1.0
done.. as of the http branch landing we cache many services in the http handler.
Status: NEW → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Verified per darin's comment.
Status: RESOLVED → VERIFIED
QA Contact: tever → junruh
You need to log in before you can comment on or make changes to this bug.