Bug 951: weaken pointer from JSObject to cache_entry
commit314a41588cb7322a01c51d5f0bc7067016c91482
authorKalle Olavi Niemitalo <kon@iki.fi>
Sat, 5 Jul 2008 01:55:16 +0000 (5 04:55 +0300)
committerKalle Olavi Niemitalo <Kalle@Astalo.kon.iki.fi>
Mon, 7 Jul 2008 20:24:43 +0000 (7 23:24 +0300)
tree5c6a810c92ea6715ab8b0c1469377facd195d3ac
parent01d5501228515fb9b959b14a37b2b99a19b7b052
Bug 951: weaken pointer from JSObject to cache_entry

The SpiderMonkey scripting module handles the "pre-format-html" event
by constructing a JSObject for the struct cache_entry and then calling
elinks.preformat_html(cache_entry, view_state) if such a function
exists.  The problem with this was that each such JSObject kept the
struct cache_entry locked until SpiderMonkey garbage-collected the
JSObject, even if the user had not defined an elinks.preformat_html
function and the JSObject was thus never needed at all.  To work
around that, the SpiderMonkey scripting module ran a garbage
collection whenever the user told ELinks to flush caches.

Remove the SpiderMonkey scripting module's use of object_lock and
object_unlock on struct cache_entry, and instead make the pointers
weak so that ELinks can free the cache_entry whenever it wants even if
a JSObject is pointing to it.  Each cache_entry now has a pointer back
to the JSObject; done_cache_entry calls smjs_detach_cache_entry_object,
which follows the pointer and detaches the cache_entry and the JSObject
from each other.

This commit does not yet remove the workaround mentioned above.
NEWS
src/cache/cache.c
src/cache/cache.h
src/scripting/smjs/cache_object.c
src/scripting/smjs/core.c
src/scripting/smjs/smjs.h