summaryrefslogtreecommitdiff
path: root/content/content.c
diff options
context:
space:
mode:
authorJames Bursa <james@netsurf-browser.org>2004-01-26 14:16:23 +0000
committerJames Bursa <james@netsurf-browser.org>2004-01-26 14:16:23 +0000
commit658084359d02596b425a27ac4c452ff65f73e1f8 (patch)
tree2cde49b9de968585587aa742f77487acaebdf7df /content/content.c
parent92941a762d0abe39136ad73562fa130fbd39db57 (diff)
downloadnetsurf-658084359d02596b425a27ac4c452ff65f73e1f8.tar.gz
netsurf-658084359d02596b425a27ac4c452ff65f73e1f8.tar.bz2
[project @ 2004-01-26 14:16:23 by bursa]
Fix crashes related to content_destroy() by adding lock, implement no_error_pages. svn path=/import/netsurf/; revision=508
Diffstat (limited to 'content/content.c')
-rw-r--r--content/content.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/content/content.c b/content/content.c
index 596672b9d..4b4e19bff 100644
--- a/content/content.c
+++ b/content/content.c
@@ -195,6 +195,8 @@ struct content * content_create(char *url)
user_sentinel->p1 = user_sentinel->p2 = 0;
user_sentinel->next = 0;
c->user_list = user_sentinel;
+ c->lock = 0;
+ c->destroy_pending = false;
return c;
}
@@ -326,8 +328,16 @@ void content_reformat(struct content *c, unsigned long width, unsigned long heig
void content_destroy(struct content *c)
{
struct content_user *user, *next;
- assert(c != 0);
+ assert(c);
LOG(("content %p %s", c, c->url));
+ assert(!c->fetch);
+ assert(!c->cache);
+
+ if (c->lock) {
+ c->destroy_pending = true;
+ return;
+ }
+
if (c->type < HANDLER_MAP_COUNT)
handler_map[c->type].destroy(c);
for (user = c->user_list; user != 0; user = next) {
@@ -435,8 +445,10 @@ void content_remove_user(struct content *c,
* and destroy content structure if not in state READY or DONE */
if (c->user_list->next == 0) {
LOG(("no users for %p %s", c, c->url));
- if (c->fetch != 0)
+ if (c->fetch != 0) {
fetch_abort(c->fetch);
+ c->fetch = 0;
+ }
if (c->status < CONTENT_STATUS_READY) {
if (c->cache)
cache_destroy(c);
@@ -444,6 +456,8 @@ void content_remove_user(struct content *c,
} else {
if (c->cache)
cache_freeable(c);
+ else
+ content_destroy(c);
}
}
}
@@ -457,11 +471,14 @@ void content_broadcast(struct content *c, content_msg msg, char *error)
{
struct content_user *user, *next;
LOG(("content %s, message %i", c->url, msg));
+ c->lock++;
for (user = c->user_list->next; user != 0; user = next) {
next = user->next; /* user may be destroyed during callback */
if (user->callback != 0)
user->callback(msg, c, user->p1, user->p2, error);
}
+ if (--(c->lock) == 0 && c->destroy_pending)
+ content_destroy(c);
}