mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Add .cached to struct document
This allows code to use document->cached instead of find_in_cache(document->uri), thereby increasing the likelihood of getting the correct cache entry. This should fix Bug 756 - "assertion (cached)->object.refcount >= 0 failed" after HTTP proxy was changed. Patches for this were written by me and then later by Jonas. This commit combines our independent implementations.
This commit is contained in:
parent
a8de4f4832
commit
e523504424
@ -503,10 +503,8 @@ display_window_title(struct session *ses, struct terminal *term)
|
|||||||
static inline void
|
static inline void
|
||||||
display_leds(struct session *ses, struct session_status *status)
|
display_leds(struct session *ses, struct session_status *status)
|
||||||
{
|
{
|
||||||
if (ses->doc_view && ses->doc_view->document
|
if (ses->doc_view && ses->doc_view->document) {
|
||||||
&& ses->doc_view->document->uri) {
|
struct cache_entry *cached = ses->doc_view->document->cached;
|
||||||
struct cache_entry *cached =
|
|
||||||
find_in_cache(ses->doc_view->document->uri);
|
|
||||||
|
|
||||||
if (cached) {
|
if (cached) {
|
||||||
if (cached->ssl_info)
|
if (cached->ssl_info)
|
||||||
|
@ -46,6 +46,7 @@ init_document(struct cache_entry *cached, struct document_options *options)
|
|||||||
|
|
||||||
object_lock(cached);
|
object_lock(cached);
|
||||||
document->id = cached->id;
|
document->id = cached->id;
|
||||||
|
document->cached = cached;
|
||||||
|
|
||||||
init_list(document->forms);
|
init_list(document->forms);
|
||||||
init_list(document->tags);
|
init_list(document->tags);
|
||||||
@ -106,19 +107,14 @@ done_link_members(struct link *link)
|
|||||||
void
|
void
|
||||||
done_document(struct document *document)
|
done_document(struct document *document)
|
||||||
{
|
{
|
||||||
struct cache_entry *cached;
|
|
||||||
|
|
||||||
assert(document);
|
assert(document);
|
||||||
if_assert_failed return;
|
if_assert_failed return;
|
||||||
|
|
||||||
assertm(!is_object_used(document), "Attempt to free locked formatted data.");
|
assertm(!is_object_used(document), "Attempt to free locked formatted data.");
|
||||||
if_assert_failed return;
|
if_assert_failed return;
|
||||||
|
|
||||||
cached = find_in_cache(document->uri);
|
assert(document->cached);
|
||||||
if (!cached)
|
object_unlock(document->cached);
|
||||||
INTERNAL("no cache entry for document");
|
|
||||||
else
|
|
||||||
object_unlock(cached);
|
|
||||||
|
|
||||||
if (document->uri) done_uri(document->uri);
|
if (document->uri) done_uri(document->uri);
|
||||||
mem_free_if(document->title);
|
mem_free_if(document->title);
|
||||||
@ -270,17 +266,14 @@ shrink_format_cache(int whole)
|
|||||||
int format_cache_entries = 0;
|
int format_cache_entries = 0;
|
||||||
|
|
||||||
foreachsafe (document, next, format_cache) {
|
foreachsafe (document, next, format_cache) {
|
||||||
struct cache_entry *cached;
|
|
||||||
|
|
||||||
if (is_object_used(document)) continue;
|
if (is_object_used(document)) continue;
|
||||||
|
|
||||||
format_cache_entries++;
|
format_cache_entries++;
|
||||||
|
|
||||||
/* Destroy obsolete renderer documents which are already
|
/* Destroy obsolete renderer documents which are already
|
||||||
* out-of-sync. */
|
* out-of-sync. */
|
||||||
cached = find_in_cache(document->uri);
|
if (document->cached->id == document->id)
|
||||||
assertm(cached, "cached formatted document has no cache entry");
|
continue;
|
||||||
if (cached->id == document->id) continue;
|
|
||||||
|
|
||||||
done_document(document);
|
done_document(document);
|
||||||
format_cache_entries--;
|
format_cache_entries--;
|
||||||
|
@ -169,6 +169,7 @@ struct document {
|
|||||||
|
|
||||||
struct uri *uri;
|
struct uri *uri;
|
||||||
unsigned char *title;
|
unsigned char *title;
|
||||||
|
struct cache_entry *cached;
|
||||||
|
|
||||||
struct frame_desc *frame;
|
struct frame_desc *frame;
|
||||||
struct frameset_desc *frame_desc; /* RENAME ME */
|
struct frameset_desc *frame_desc; /* RENAME ME */
|
||||||
|
@ -64,9 +64,10 @@ check_document_fragment(struct session *ses, struct document_view *doc_view)
|
|||||||
/* Omit the leading '#' when calling find_tag. */
|
/* Omit the leading '#' when calling find_tag. */
|
||||||
vy = find_tag(document, fragment.source + 1, fragment.length - 1);
|
vy = find_tag(document, fragment.source + 1, fragment.length - 1);
|
||||||
if (vy == -1) {
|
if (vy == -1) {
|
||||||
struct cache_entry *cached = find_in_cache(document->uri);
|
struct cache_entry *cached = document->cached;
|
||||||
|
|
||||||
if (!cached || cached->incomplete || cached->id != document->id) {
|
assert(cached);
|
||||||
|
if (cached->incomplete || cached->id != document->id) {
|
||||||
done_string(&fragment);
|
done_string(&fragment);
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user