RESOLVED FIXED 22380
Fix WorkerContext refcounting
https://bugs.webkit.org/show_bug.cgi?id=22380
Summary Fix WorkerContext refcounting
Alexey Proskuryakov
Reported 2008-11-20 05:05:16 PST
WorkerContext is not currently destroyed when its thread finishes, because its JS wrapper holds a reference to it. We need to clear destroy the JS heap before the thread finishes.
Attachments
proposed patch (2.94 KB, patch)
2008-11-20 05:08 PST, Alexey Proskuryakov
darin: review+
Alexey Proskuryakov
Comment 1 2008-11-20 05:08:18 PST
Created attachment 25311 [details] proposed patch
Darin Adler
Comment 2 2008-11-20 09:24:59 PST
Comment on attachment 25311 [details] proposed patch > + , m_script(new WorkerScriptController(this)) For future consideration: We want to try to avoid bare "new" calls almost everywhere. For single-owner classes, I think a create function that returns auto_ptr is a good design. We can change OwnPtr so it has a constructor that takes an auto_ptr, if it doesn't already have one. For reference counted classes a create function that returns PassRefPtr is obviously our approach. > + workerContext->clearScript(); > + ASSERT(workerContext->refCount() == 1); I think you should add a comment here explaining why there's a guarantee that no one else is holding a reference. Our usual aim with reference-counted objects is to make the "shutdown" operation be something other than destruction, and always allow someone to prolong the lifetime of the object a bit, just to keep a pointer valid. I know we don't always use reference counting that way, but I think it merits a comment when we're not. By the way, can you use the hasOneRef() function here instead? r=me
Alexey Proskuryakov
Comment 3 2008-11-20 12:37:08 PST
Committed revision 38626. Added a comment that hopefully clarifies the behavior a little, and changed to hasOneRef, which is better.
Note You need to log in before you can comment on or make changes to this bug.