netsurf: branch master updated. release/3.0-1134-g60973fe
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/60973fe5d1da545b0c993...
...commit http://git.netsurf-browser.org/netsurf.git/commit/60973fe5d1da545b0c993df...
...tree http://git.netsurf-browser.org/netsurf.git/tree/60973fe5d1da545b0c993df12...
The branch, master has been updated
via 60973fe5d1da545b0c993df1261e6b649c7b4dd9 (commit)
via ff8c37a6eeed79eafb8693fa80ece4c05eb46527 (commit)
from 4591b65ad9003797e6af477ed84cc2279a661b91 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=60973fe5d1da545b0c9...
commit 60973fe5d1da545b0c993df1261e6b649c7b4dd9
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
Make llcache debugging less invasive
diff --git a/content/llcache.c b/content/llcache.c
index b5e2930..bd7ae93 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -38,6 +38,12 @@
/** Define to enable tracing of llcache operations. */
#undef LLCACHE_TRACE
+#ifdef LLCACHE_TRACE
+#define LLCACHE_LOG(x) LOG(x)
+#else
+#define LLCACHE_LOG(x)
+#endif
+
/** State of a low-level cache object fetch */
typedef enum {
LLCACHE_FETCH_INIT, /**< Initial state, before fetch */
@@ -200,9 +206,7 @@ static nserror llcache_object_user_new(llcache_handle_callback cb, void *pw,
u->handle = h;
-#ifdef LLCACHE_TRACE
- LOG(("Created user %p (%p, %p, %p)", u, h, (void *) cb, pw));
-#endif
+ LLCACHE_LOG(("Created user %p (%p, %p, %p)", u, h, (void *) cb, pw));
*user = u;
@@ -219,9 +223,7 @@ static nserror llcache_object_user_new(llcache_handle_callback cb, void *pw,
*/
static nserror llcache_object_user_destroy(llcache_object_user *user)
{
-#ifdef LLCACHE_TRACE
- LOG(("Destroyed user %p", user));
-#endif
+ LLCACHE_LOG(("Destroyed user %p", user));
assert(user->next == NULL);
assert(user->prev == NULL);
@@ -260,9 +262,7 @@ static nserror llcache_object_remove_user(llcache_object *object,
user->next = user->prev = NULL;
-#ifdef LLCACHE_TRACE
- LOG(("Removing user %p from %p", user, object));
-#endif
+ LLCACHE_LOG(("Removing user %p from %p", user, object));
return NSERROR_OK;
}
@@ -318,9 +318,7 @@ static nserror llcache_object_new(nsurl *url, llcache_object **result)
if (obj == NULL)
return NSERROR_NOMEM;
-#ifdef LLCACHE_TRACE
- LOG(("Created object %p (%s)", obj, nsurl_access(url)));
-#endif
+ LLCACHE_LOG(("Created object %p (%s)", obj, nsurl_access(url)));
obj->url = nsurl_ref(url);
@@ -703,9 +701,7 @@ static nserror llcache_object_refetch(llcache_object *object)
/* Reset fetch state */
object->fetch.state = LLCACHE_FETCH_INIT;
-#ifdef LLCACHE_TRACE
- LOG(("Refetching %p", object));
-#endif
+ LLCACHE_LOG(("Refetching %p", object));
/* Kick off fetch */
object->fetch.fetch = fetch_start(object->url, object->fetch.referer,
@@ -751,9 +747,7 @@ static nserror llcache_object_fetch(llcache_object *object, uint32_t flags,
nsurl *referer_clone = NULL;
llcache_post_data *post_clone = NULL;
-#ifdef LLCACHE_TRACE
- LOG(("Starting fetch for %p", object));
-#endif
+ LLCACHE_LOG(("Starting fetch for %p", object));
if (post != NULL) {
error = llcache_post_data_clone(post, &post_clone);
@@ -786,9 +780,7 @@ static nserror llcache_object_destroy(llcache_object *object)
{
size_t i;
-#ifdef LLCACHE_TRACE
- LOG(("Destroying object %p", object));
-#endif
+ LLCACHE_LOG(("Destroying object %p", object));
nsurl_unref(object->url);
free(object->source_data);
@@ -872,9 +864,7 @@ llcache_object_rfc2616_remaining_lifetime(const llcache_cache_control *cd)
else
freshness_lifetime = 0;
-#ifdef LLCACHE_TRACE
- LOG(("%d:%d", freshness_lifetime, current_age));
-#endif
+ LLCACHE_LOG(("%d:%d", freshness_lifetime, current_age));
if ((cd->no_cache == LLCACHE_VALIDATE_FRESH) &&
(freshness_lifetime > current_age)) {
@@ -903,11 +893,9 @@ static bool llcache_object_is_fresh(const llcache_object *object)
remaining_lifetime = llcache_object_rfc2616_remaining_lifetime(cd);
-#ifdef LLCACHE_TRACE
- LOG(("%p: (%d > 0 || %d != %d)", object,
+ LLCACHE_LOG(("%p: (%d > 0 || %d != %d)", object,
remaining_lifetime,
object->fetch.state, LLCACHE_FETCH_COMPLETE));
-#endif
/* The object is fresh if:
* - it was not forbidden from being returned from the cache
@@ -995,9 +983,8 @@ static nserror llcache_object_retrieve_from_cache(nsurl *url, uint32_t flags,
nserror error;
llcache_object *obj, *newest = NULL;
-#ifdef LLCACHE_TRACE
- LOG(("Searching cache for %s (%x %s %p)", url, flags, referer, post));
-#endif
+ LLCACHE_LOG(("Searching cache for %s (%x %p %p)",
+ nsurl_access(url), flags, referer, post));
/* Search for the most recently fetched matching object */
for (obj = llcache->cached_objects; obj != NULL; obj = obj->next) {
@@ -1014,9 +1001,7 @@ static nserror llcache_object_retrieve_from_cache(nsurl *url, uint32_t flags,
/* Found a suitable object, and it's still fresh, so use it */
obj = newest;
-#ifdef LLCACHE_TRACE
- LOG(("Found fresh %p", obj));
-#endif
+ LLCACHE_LOG(("Found fresh %p", obj));
/* The client needs to catch up with the object's state.
* This will occur the next time that llcache_poll is called.
@@ -1029,9 +1014,7 @@ static nserror llcache_object_retrieve_from_cache(nsurl *url, uint32_t flags,
if (error != NSERROR_OK)
return error;
-#ifdef LLCACHE_TRACE
- LOG(("Found candidate %p (%p)", obj, newest));
-#endif
+ LLCACHE_LOG(("Found candidate %p (%p)", obj, newest));
/* Clone candidate's cache data */
error = llcache_object_clone_cache_data(newest, obj, true);
@@ -1062,9 +1045,7 @@ static nserror llcache_object_retrieve_from_cache(nsurl *url, uint32_t flags,
if (error != NSERROR_OK)
return error;
-#ifdef LLCACHE_TRACE
- LOG(("Not found %p", obj));
-#endif
+ LLCACHE_LOG(("Not found %p", obj));
/* Attempt to kick-off fetch */
error = llcache_object_fetch(obj, flags, referer, post,
@@ -1103,9 +1084,8 @@ static nserror llcache_object_retrieve(nsurl *url, uint32_t flags,
bool has_query;
nsurl *defragmented_url;
-#ifdef LLCACHE_TRACE
- LOG(("Retrieve %s (%x, %s, %p)", url, flags, referer, post));
-#endif
+ LLCACHE_LOG(("Retrieve %s (%x, %p, %p)",
+ nsurl_access(url), flags, referer, post));
/**
* Caching Rules:
@@ -1158,9 +1138,7 @@ static nserror llcache_object_retrieve(nsurl *url, uint32_t flags,
obj->has_query = has_query;
-#ifdef LLCACHE_TRACE
- LOG(("Retrieved %p", obj));
-#endif
+ LLCACHE_LOG(("Retrieved %p", obj));
*result = obj;
@@ -1192,9 +1170,7 @@ static nserror llcache_object_add_user(llcache_object *object,
object->users->prev = user;
object->users = user;
-#ifdef LLCACHE_TRACE
- LOG(("Adding user %p to %p", user, object));
-#endif
+ LLCACHE_LOG(("Adding user %p to %p", user, object));
return NSERROR_OK;
}
@@ -1636,9 +1612,7 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
llcache_object *object = p;
llcache_event event;
-#ifdef LLCACHE_TRACE
- LOG(("Fetch event %d for %p", msg->type, object));
-#endif
+ LLCACHE_LOG(("Fetch event %d for %p", msg->type, object));
switch (msg->type) {
case FETCH_HEADER:
@@ -2180,9 +2154,7 @@ void llcache_clean(void)
uint32_t llcache_size = 0;
int remaining_lifetime;
-#ifdef LLCACHE_TRACE
- LOG(("Attempting cache clean"));
-#endif
+ LLCACHE_LOG(("Attempting cache clean"));
/* Candidates for cleaning are (in order of priority):
*
@@ -2200,9 +2172,8 @@ void llcache_clean(void)
(object->candidate_count == 0) &&
(object->fetch.fetch == NULL) &&
(object->fetch.outstanding_query == false)) {
-#ifdef LLCACHE_TRACE
- LOG(("Found victim %p", object));
-#endif
+ LLCACHE_LOG(("Found victim %p", object));
+
llcache_object_remove_from_list(object,
&llcache->uncached_objects);
llcache_object_destroy(object);
@@ -2227,9 +2198,8 @@ void llcache_clean(void)
llcache_size += object->source_len + sizeof(*object);
} else {
/* object is not fresh */
-#ifdef LLCACHE_TRACE
- LOG(("Found stale cacheable object (%p) with no users or pending fetches", object));
-#endif
+ LLCACHE_LOG(("Found stale cacheable object (%p) with no users or pending fetches", object));
+
llcache_object_remove_from_list(object,
&llcache->cached_objects);
llcache_object_destroy(object);
@@ -2251,9 +2221,8 @@ void llcache_clean(void)
(object->candidate_count == 0) &&
(object->fetch.fetch == NULL) &&
(object->fetch.outstanding_query == false)) {
-#ifdef LLCACHE_TRACE
- LOG(("Found victim %p", object));
-#endif
+ LLCACHE_LOG(("Found victim %p", object));
+
llcache_size -=
object->source_len + sizeof(*object);
@@ -2264,10 +2233,7 @@ void llcache_clean(void)
}
}
-#ifdef LLCACHE_TRACE
- LOG(("Size: %u", llcache_size));
-#endif
-
+ LLCACHE_LOG(("Size: %u", llcache_size));
}
/* See llcache.h for documentation */
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=ff8c37a6eeed79eafb8...
commit ff8c37a6eeed79eafb8693fa80ece4c05eb46527
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
Witespace cleanup to prepare for backing store addition
diff --git a/content/llcache.c b/content/llcache.c
index e4baec6..b5e2930 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -75,7 +75,7 @@ typedef struct llcache_object_user {
typedef struct {
uint32_t flags; /**< Fetch flags */
nsurl *referer; /**< Referring URL, or NULL if none */
- llcache_post_data *post; /**< POST data, or NULL for GET */
+ llcache_post_data *post; /**< POST data, or NULL for GET */
struct fetch *fetch; /**< Fetch handle for this object */
@@ -124,7 +124,7 @@ struct llcache_object {
nsurl *url; /**< Post-redirect URL for object */
bool has_query; /**< URL has a query segment */
-
+
/** \todo We need a generic dynamic buffer object */
uint8_t *source_data; /**< Source data for object */
size_t source_len; /**< Byte length of source data */
@@ -137,7 +137,7 @@ struct llcache_object {
llcache_cache_control cache; /**< Cache control data for object */
llcache_object *candidate; /**< Object to use, if fetch determines
* that it is still fresh */
- uint32_t candidate_count; /**< Count of objects this is a
+ uint32_t candidate_count; /**< Count of objects this is a
* candidate for */
llcache_header *headers; /**< Fetch headers */
@@ -222,10 +222,10 @@ static nserror llcache_object_user_destroy(llcache_object_user *user)
#ifdef LLCACHE_TRACE
LOG(("Destroyed user %p", user));
#endif
-
+
assert(user->next == NULL);
assert(user->prev == NULL);
-
+
if (user->handle != NULL)
free(user->handle);
@@ -241,7 +241,7 @@ static nserror llcache_object_user_destroy(llcache_object_user *user)
* \param user User to remove
* \return NSERROR_OK.
*/
-static nserror llcache_object_remove_user(llcache_object *object,
+static nserror llcache_object_remove_user(llcache_object *object,
llcache_object_user *user)
{
assert(user != NULL);
@@ -249,7 +249,7 @@ static nserror llcache_object_remove_user(llcache_object *object,
assert(object->users != NULL);
assert(user->handle == NULL || user->handle->object == object);
assert((user->prev != NULL) || (object->users == user));
-
+
if (user == object->users)
object->users = user->next;
else
@@ -257,9 +257,9 @@ static nserror llcache_object_remove_user(llcache_object *object,
if (user->next != NULL)
user->next->prev = user->prev;
-
+
user->next = user->prev = NULL;
-
+
#ifdef LLCACHE_TRACE
LOG(("Removing user %p from %p", user, object));
#endif
@@ -279,7 +279,7 @@ static nserror llcache_send_event_to_users(llcache_object *object,
{
nserror error = NSERROR_OK;
llcache_object_user *user, *next_user;
-
+
user = object->users;
while (user != NULL) {
user->iterator_target = true;
@@ -301,7 +301,7 @@ static nserror llcache_send_event_to_users(llcache_object *object,
user = next_user;
}
-
+
return error;
}
@@ -336,7 +336,7 @@ static nserror llcache_object_new(nsurl *url, llcache_object **result)
* \param clone Pointer to location to receive clone
* \return NSERROR_OK on success, appropriate error otherwise
*/
-static nserror llcache_post_data_clone(const llcache_post_data *orig,
+static nserror llcache_post_data_clone(const llcache_post_data *orig,
llcache_post_data **clone)
{
llcache_post_data *post_clone;
@@ -379,7 +379,7 @@ static nserror llcache_post_data_clone(const llcache_post_data *orig,
* \param value Pointer to location to receive header value
* \return NSERROR_OK on success, appropriate error otherwise
*/
-static nserror llcache_fetch_split_header(const uint8_t *data, size_t len,
+static nserror llcache_fetch_split_header(const uint8_t *data, size_t len,
char **name, char **value)
{
char *n, *v;
@@ -408,8 +408,8 @@ static nserror llcache_fetch_split_header(const uint8_t *data, size_t len,
}
/* Strip trailing whitespace from name */
- while (colon > data && (colon[-1] == ' ' ||
- colon[-1] == '\t' || colon[-1] == '\r' ||
+ while (colon > data && (colon[-1] == ' ' ||
+ colon[-1] == '\t' || colon[-1] == '\r' ||
colon[-1] == '\n'))
colon--;
@@ -425,12 +425,12 @@ static nserror llcache_fetch_split_header(const uint8_t *data, size_t len,
/* Skip over colon and any subsequent whitespace */
do {
colon++;
- } while (*colon == ' ' || *colon == '\t' ||
+ } while (*colon == ' ' || *colon == '\t' ||
*colon == '\r' || *colon == '\n');
/* Strip trailing whitespace from value */
- while (len > 0 && (data[len - 1] == ' ' ||
- data[len - 1] == '\t' ||
+ while (len > 0 && (data[len - 1] == ' ' ||
+ data[len - 1] == '\t' ||
data[len - 1] == '\r' ||
data[len - 1] == '\n')) {
len--;
@@ -459,11 +459,11 @@ static nserror llcache_fetch_split_header(const uint8_t *data, size_t len,
* \param value Pointer to location to receive header value
* \return NSERROR_OK on success, appropriate error otherwise
*
- * \note This function also has the side-effect of updating
+ * \note This function also has the side-effect of updating
* the cache control data for the object if an interesting
* header is encountered
*/
-static nserror llcache_fetch_parse_header(llcache_object *object,
+static nserror llcache_fetch_parse_header(llcache_object *object,
const uint8_t *data, size_t len, char **name, char **value)
{
nserror error;
@@ -499,13 +499,13 @@ static nserror llcache_fetch_parse_header(llcache_object *object,
while (*comma != '\0' && *comma != ',')
comma++;
- if (8 < comma - start && (strncasecmp(start,
- "no-cache", 8) == 0 ||
+ if (8 < comma - start && (strncasecmp(start,
+ "no-cache", 8) == 0 ||
strncasecmp(start, "no-store", 8) == 0))
/* When we get a disk cache we should
* distinguish between these two */
object->cache.no_cache = LLCACHE_VALIDATE_ALWAYS;
- else if (7 < comma - start &&
+ else if (7 < comma - start &&
strncasecmp(start, "max-age", 7) == 0) {
/* Find '=' */
while (start < comma && *start != '=')
@@ -547,7 +547,7 @@ static nserror llcache_fetch_parse_header(llcache_object *object,
#undef SKIP_ST
- return NSERROR_OK;
+ return NSERROR_OK;
}
/* Destroy headers */
@@ -581,7 +581,7 @@ static inline void llcache_invalidate_cache_control_data(llcache_object *object)
* \param len Byte length of header
* \return NSERROR_OK on success, appropriate error otherwise
*/
-static nserror llcache_fetch_process_header(llcache_object *object,
+static nserror llcache_fetch_process_header(llcache_object *object,
const uint8_t *data, size_t len)
{
nserror error;
@@ -589,14 +589,14 @@ static nserror llcache_fetch_process_header(llcache_object *object,
llcache_header *temp;
/* The headers for multiple HTTP responses may be delivered to us if
- * the fetch layer receives a 401 response for which it has
+ * the fetch layer receives a 401 response for which it has
* authentication credentials. This will result in a silent re-request
* after which we'll receive the actual response headers for the
* object we want to fetch (assuming that the credentials were correct
* of course)
*
- * Therefore, if the header is an HTTP response start marker, then we
- * must discard any headers we've read so far, reset the cache data
+ * Therefore, if the header is an HTTP response start marker, then we
+ * must discard any headers we've read so far, reset the cache data
* that we might have computed, and start again.
*/
/** \todo Properly parse the response line */
@@ -617,7 +617,7 @@ static nserror llcache_fetch_process_header(llcache_object *object,
}
/* Append header data to the object's headers array */
- temp = realloc(object->headers, (object->num_headers + 1) *
+ temp = realloc(object->headers, (object->num_headers + 1) *
sizeof(llcache_header));
if (temp == NULL) {
free(name);
@@ -642,7 +642,7 @@ static nserror llcache_fetch_process_header(llcache_object *object,
* \return NSERROR_OK on success, appropriate error otherwise
*
* \pre The fetch parameters in object->fetch must be populated
- */
+ */
static nserror llcache_object_refetch(llcache_object *object)
{
const char *urlenc = NULL;
@@ -663,7 +663,7 @@ static nserror llcache_object_refetch(llcache_object *object)
return NSERROR_NOMEM;
if (object->cache.etag != NULL) {
- const size_t len = SLEN("If-None-Match: ") +
+ const size_t len = SLEN("If-None-Match: ") +
strlen(object->cache.etag) + 1;
headers[header_idx] = malloc(len);
@@ -739,7 +739,7 @@ static nserror llcache_object_refetch(llcache_object *object)
* \return NSERROR_OK on success, appropriate error otherwise
*
* \pre object::url must contain the URL to fetch
- * \pre If there is a freshness validation candidate,
+ * \pre If there is a freshness validation candidate,
* object::candidate and object::cache must be filled in
* \pre There must not be a fetch in progress for \a object
*/
@@ -913,7 +913,7 @@ static bool llcache_object_is_fresh(const llcache_object *object)
* - it was not forbidden from being returned from the cache
* unvalidated.
*
- * - it has remaining lifetime or still being fetched.
+ * - it has remaining lifetime or still being fetched.
*/
return ((cd->no_cache == LLCACHE_VALIDATE_FRESH) &&
((remaining_lifetime > 0) ||
@@ -970,7 +970,7 @@ static nserror llcache_object_clone_cache_data(llcache_object *source,
if (source->cache.no_cache != LLCACHE_VALIDATE_FRESH)
destination->cache.no_cache = source->cache.no_cache;
-
+
if (source->cache.last_modified != 0)
destination->cache.last_modified = source->cache.last_modified;
@@ -1002,7 +1002,7 @@ static nserror llcache_object_retrieve_from_cache(nsurl *url, uint32_t flags,
/* Search for the most recently fetched matching object */
for (obj = llcache->cached_objects; obj != NULL; obj = obj->next) {
- if ((newest == NULL ||
+ if ((newest == NULL ||
obj->cache.req_time > newest->cache.req_time) &&
nsurl_compare(obj->url, url,
NSURL_COMPLETE) == true) {
@@ -1038,7 +1038,7 @@ static nserror llcache_object_retrieve_from_cache(nsurl *url, uint32_t flags,
if (error != NSERROR_OK) {
llcache_object_destroy(obj);
return error;
- }
+ }
/* Record candidate, so we can fall back if it is still fresh */
newest->candidate_count++;
@@ -1135,7 +1135,7 @@ static nserror llcache_object_retrieve(nsurl *url, uint32_t flags,
}
/* Attempt to kick-off fetch */
- error = llcache_object_fetch(obj, flags, referer, post,
+ error = llcache_object_fetch(obj, flags, referer, post,
redirect_count);
if (error != NSERROR_OK) {
llcache_object_destroy(obj);
@@ -1155,17 +1155,17 @@ static nserror llcache_object_retrieve(nsurl *url, uint32_t flags,
/* Returned object is already in the cached list */
}
-
+
obj->has_query = has_query;
#ifdef LLCACHE_TRACE
LOG(("Retrieved %p", obj));
#endif
-
+
*result = obj;
-
+
nsurl_unref(defragmented_url);
-
+
return NSERROR_OK;
}
@@ -1225,13 +1225,13 @@ static nserror llcache_fetch_redirect(llcache_object *object, const char *target
/* Abort fetch for this object */
fetch_abort(object->fetch.fetch);
object->fetch.fetch = NULL;
-
+
/* Invalidate the cache control data */
llcache_invalidate_cache_control_data(object);
/* And mark it complete */
object->fetch.state = LLCACHE_FETCH_COMPLETE;
-
+
/* Forcibly stop redirecting if we've followed too many redirects */
#define REDIRECT_LIMIT 10
if (object->fetch.redirect_count > REDIRECT_LIMIT) {
@@ -1239,7 +1239,7 @@ static nserror llcache_fetch_redirect(llcache_object *object, const char *target
event.type = LLCACHE_EVENT_ERROR;
event.data.msg = messages_get("BadRedirect");
-
+
return llcache_send_event_to_users(object, &event);
}
#undef REDIRECT_LIMIT
@@ -1306,7 +1306,7 @@ static nserror llcache_fetch_redirect(llcache_object *object, const char *target
/* Attempt to fetch target URL */
error = llcache_object_retrieve(url, object->fetch.flags,
- object->fetch.referer, post,
+ object->fetch.referer, post,
object->fetch.redirect_count + 1, &dest);
/* No longer require url */
@@ -1326,7 +1326,7 @@ static nserror llcache_fetch_redirect(llcache_object *object, const char *target
/* Dest is now our object */
*replacement = dest;
- return NSERROR_OK;
+ return NSERROR_OK;
}
/**
@@ -1373,14 +1373,14 @@ static nserror llcache_fetch_notmodified(llcache_object *object,
object->candidate->candidate_count--;
/* Clone our cache control data into the candidate */
- llcache_object_clone_cache_data(object, object->candidate,
+ llcache_object_clone_cache_data(object, object->candidate,
false);
/* Bring candidate's cache data up to date */
llcache_object_cache_update(object->candidate);
/* Revert no-cache to normal, if required */
- if (object->candidate->cache.no_cache ==
+ if (object->candidate->cache.no_cache ==
LLCACHE_VALIDATE_ONCE) {
- object->candidate->cache.no_cache =
+ object->candidate->cache.no_cache =
LLCACHE_VALIDATE_FRESH;
}
@@ -1415,7 +1415,7 @@ static nserror llcache_fetch_notmodified(llcache_object *object,
* \param len Byte length of data
* \return NSERROR_OK on success, appropriate error otherwise.
*/
-static nserror llcache_fetch_process_data(llcache_object *object, const uint8_t *data,
+static nserror llcache_fetch_process_data(llcache_object *object, const uint8_t *data,
size_t len)
{
/* Resize source buffer if it's too small */
@@ -1464,7 +1464,7 @@ static nserror llcache_query_handle_response(bool proceed, void *cbpw)
event.type = LLCACHE_EVENT_ERROR;
/** \todo More appropriate error message */
event.data.msg = messages_get("FetchFailed");
-
+
return llcache_send_event_to_users(object, &event);
}
@@ -1511,7 +1511,7 @@ static nserror llcache_fetch_auth(llcache_object *object, const char *realm)
object->fetch.outstanding_query = true;
- error = llcache->query_cb(&query, llcache->query_cb_pw,
+ error = llcache->query_cb(&query, llcache->query_cb_pw,
llcache_query_handle_response, object);
} else {
llcache_event event;
@@ -1523,7 +1523,7 @@ static nserror llcache_fetch_auth(llcache_object *object, const char *realm)
event.type = LLCACHE_EVENT_ERROR;
/** \todo More appropriate error message */
event.data.msg = messages_get("FetchFailed");
-
+
error = llcache_send_event_to_users(object, &event);
}
} else {
@@ -1578,7 +1578,7 @@ static nserror llcache_fetch_cert_error(llcache_object *object,
event.type = LLCACHE_EVENT_ERROR;
/** \todo More appropriate error message */
event.data.msg = messages_get("FetchFailed");
-
+
error = llcache_send_event_to_users(object, &event);
}
@@ -1612,7 +1612,7 @@ static nserror llcache_fetch_ssl_error(llcache_object *object)
event.type = LLCACHE_EVENT_ERROR;
/** \todo More appropriate error message */
event.data.msg = messages_get("FetchFailed");
-
+
error = llcache_send_event_to_users(object, &event);
} else {
/* Flag that we've tried to downgrade, so that if the
@@ -1645,8 +1645,8 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
/* Received a fetch header */
object->fetch.state = LLCACHE_FETCH_HEADERS;
- error = llcache_fetch_process_header(object,
- msg->data.header_or_data.buf,
+ error = llcache_fetch_process_header(object,
+ msg->data.header_or_data.buf,
msg->data.header_or_data.len);
break;
@@ -1660,7 +1660,7 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
object->candidate = NULL;
}
- error = llcache_fetch_redirect(object,
+ error = llcache_fetch_redirect(object,
msg->data.redirect, &object);
break;
case FETCH_NOTMODIFIED:
@@ -1672,7 +1672,7 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
case FETCH_DATA:
/* Received some data */
if (object->fetch.state != LLCACHE_FETCH_DATA) {
- /* On entry into this state, check if we need to
+ /* On entry into this state, check if we need to
* invalidate the cache control data. We are guaranteed
* to have received all response headers.
*
@@ -1687,7 +1687,7 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
long http_code = fetch_http_code(object->fetch.fetch);
if ((http_code != 200 && http_code != 203) ||
- (object->has_query &&
+ (object->has_query &&
(object->cache.max_age == INVALID_AGE &&
object->cache.expires == 0))) {
/* Invalidate cache control data */
@@ -1703,7 +1703,7 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
object->fetch.state = LLCACHE_FETCH_DATA;
- error = llcache_fetch_process_data(object,
+ error = llcache_fetch_process_data(object,
msg->data.header_or_data.buf,
msg->data.header_or_data.len);
break;
@@ -1716,7 +1716,7 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
object->fetch.fetch = NULL;
/* Shrink source buffer to required size */
- temp = realloc(object->source_data,
+ temp = realloc(object->source_data,
object->source_len);
/* If source_len is 0, then temp may be NULL */
if (temp != NULL || object->source_len == 0) {
@@ -1748,9 +1748,9 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
event.type = LLCACHE_EVENT_ERROR;
event.data.msg = msg->data.error;
-
+
error = llcache_send_event_to_users(object, &event);
-
+
break;
case FETCH_PROGRESS:
/* Progress update */
@@ -1758,7 +1758,7 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
event.data.msg = msg->data.progress;
error = llcache_send_event_to_users(object, &event);
-
+
break;
/* Events requiring action */
@@ -1782,8 +1782,8 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
object->candidate = NULL;
}
- error = llcache_fetch_cert_error(object,
- msg->data.cert_err.certs,
+ error = llcache_fetch_cert_error(object,
+ msg->data.cert_err.certs,
msg->data.cert_err.num_certs);
break;
case FETCH_SSL_ERR:
@@ -1892,7 +1892,7 @@ static nserror llcache_object_notify_users(llcache_object *object)
#endif
/**
- * State transitions and event emission for users.
+ * State transitions and event emission for users.
* Rows: user state. Cols: object state.
*
* User\Obj INIT HEADERS DATA COMPLETE
@@ -1924,8 +1924,8 @@ static nserror llcache_object_notify_users(llcache_object *object)
user->iterator_target = true;
/* A note on the computation of next_user:
- *
- * Within this loop, we may make a number of calls to
+ *
+ * Within this loop, we may make a number of calls to
* client code. Our contract with clients is that they
* can do whatever they like from within their callback
* handlers. This is so that we limit the pain of
@@ -1936,7 +1936,7 @@ static nserror llcache_object_notify_users(llcache_object *object)
* user list. In the common case, the user they attempt
* to remove is the current iteration target, and we
* already protect against that causing problems here.
- * However, no such protection exists if the client
+ * However, no such protection exists if the client
* attempts to remove other users from this object's
* user list.
*
@@ -1957,13 +1957,13 @@ static nserror llcache_object_notify_users(llcache_object *object)
emitted_notify = true;
}
- LOG(("User %p state: %d Object state: %d",
+ LOG(("User %p state: %d Object state: %d",
user, handle->state, objstate));
}
#endif
/* User: INIT, Obj: HEADERS, DATA, COMPLETE => User->HEADERS */
- if (handle->state == LLCACHE_FETCH_INIT &&
+ if (handle->state == LLCACHE_FETCH_INIT &&
objstate > LLCACHE_FETCH_INIT) {
handle->state = LLCACHE_FETCH_HEADERS;
}
@@ -1991,7 +1991,7 @@ static nserror llcache_object_notify_users(llcache_object *object)
/* User requested replay */
handle->state = LLCACHE_FETCH_HEADERS;
- /* Continue with the next user -- we'll
+ /* Continue with the next user -- we'll
* reemit the event next time round */
user->iterator_target = false;
next_user = user->next;
@@ -2010,15 +2010,15 @@ static nserror llcache_object_notify_users(llcache_object *object)
/* Construct HAD_DATA event */
event.type = LLCACHE_EVENT_HAD_DATA;
- event.data.data.buf =
+ event.data.data.buf =
object->source_data + handle->bytes;
- event.data.data.len =
+ event.data.data.len =
object->source_len - handle->bytes;
/* Update record of last byte emitted */
- if (object->fetch.flags &
+ if (object->fetch.flags &
LLCACHE_RETRIEVE_STREAM_DATA) {
- /* Streaming, so reset to zero to
+ /* Streaming, so reset to zero to
* minimise amount of cached source data.
* Additionally, we don't support replay
* when streaming. */
@@ -2044,7 +2044,7 @@ static nserror llcache_object_notify_users(llcache_object *object)
/* User requested replay */
handle->bytes = orig_handle_read;
- /* Continue with the next user -- we'll
+ /* Continue with the next user -- we'll
* reemit the data next time round */
user->iterator_target = false;
next_user = user->next;
@@ -2077,7 +2077,7 @@ static nserror llcache_object_notify_users(llcache_object *object)
/* User requested replay */
handle->state = LLCACHE_FETCH_DATA;
- /* Continue with the next user -- we'll
+ /* Continue with the next user -- we'll
* reemit the event next time round */
user->iterator_target = false;
next_user = user->next;
@@ -2116,37 +2116,37 @@ static nserror llcache_object_snapshot(llcache_object *object,
{
llcache_object *newobj;
nserror error;
-
+
error = llcache_object_new(object->url, &newobj);
-
+
if (error != NSERROR_OK)
return error;
-
+
newobj->has_query = object->has_query;
newobj->source_alloc = newobj->source_len = object->source_len;
-
+
if (object->source_len > 0) {
newobj->source_data = malloc(newobj->source_alloc);
if (newobj->source_data == NULL) {
llcache_object_destroy(newobj);
return NSERROR_NOMEM;
}
- memcpy(newobj->source_data, object->source_data,
+ memcpy(newobj->source_data, object->source_data,
newobj->source_len);
}
-
+
if (object->num_headers > 0) {
- newobj->headers = calloc(sizeof(llcache_header),
+ newobj->headers = calloc(sizeof(llcache_header),
object->num_headers);
if (newobj->headers == NULL) {
llcache_object_destroy(newobj);
return NSERROR_NOMEM;
}
while (newobj->num_headers < object->num_headers) {
- llcache_header *nh =
+ llcache_header *nh =
&(newobj->headers[newobj->num_headers]);
- llcache_header *oh =
+ llcache_header *oh =
&(object->headers[newobj->num_headers]);
newobj->num_headers += 1;
nh->name = strdup(oh->name);
@@ -2157,11 +2157,11 @@ static nserror llcache_object_snapshot(llcache_object *object,
}
}
}
-
+
newobj->fetch.state = LLCACHE_FETCH_COMPLETE;
-
+
*snapshot = newobj;
-
+
return NSERROR_OK;
}
@@ -2185,7 +2185,7 @@ void llcache_clean(void)
#endif
/* Candidates for cleaning are (in order of priority):
- *
+ *
* 1) Uncacheable objects with no users
* 2) Stale cacheable objects with no users or pending fetches
* 3) Fresh cacheable objects with no users or pending fetches
@@ -2196,14 +2196,14 @@ void llcache_clean(void)
next = object->next;
/* The candidate count of uncacheable objects is always 0 */
- if ((object->users == NULL) &&
+ if ((object->users == NULL) &&
(object->candidate_count == 0) &&
(object->fetch.fetch == NULL) &&
(object->fetch.outstanding_query == false)) {
#ifdef LLCACHE_TRACE
LOG(("Found victim %p", object));
#endif
- llcache_object_remove_from_list(object,
+ llcache_object_remove_from_list(object,
&llcache->uncached_objects);
llcache_object_destroy(object);
} else {
@@ -2243,18 +2243,18 @@ void llcache_clean(void)
* fetches, only if the cache exceeds the configured size.
*/
if (llcache->limit < llcache_size) {
- for (object = llcache->cached_objects; object != NULL;
+ for (object = llcache->cached_objects; object != NULL;
object = next) {
next = object->next;
- if ((object->users == NULL) &&
+ if ((object->users == NULL) &&
(object->candidate_count == 0) &&
(object->fetch.fetch == NULL) &&
(object->fetch.outstanding_query == false)) {
#ifdef LLCACHE_TRACE
LOG(("Found victim %p", object));
#endif
- llcache_size -=
+ llcache_size -=
object->source_len + sizeof(*object);
llcache_object_remove_from_list(object,
@@ -2271,7 +2271,7 @@ void llcache_clean(void)
}
/* See llcache.h for documentation */
-nserror
+nserror
llcache_initialise(llcache_query_callback cb, void *pw, uint32_t llcache_limit)
{
llcache = calloc(1, sizeof(struct llcache_s));
@@ -2330,7 +2330,7 @@ void llcache_finalise(void)
}
/* Fetch system has already been destroyed */
- object->fetch.fetch = NULL;
+ object->fetch.fetch = NULL;
llcache_object_destroy(object);
}
@@ -2343,11 +2343,11 @@ void llcache_finalise(void)
nserror llcache_poll(void)
{
llcache_object *object;
-
+
fetch_poll();
-
+
/* Catch new users up with state of objects */
- for (object = llcache->cached_objects; object != NULL;
+ for (object = llcache->cached_objects; object != NULL;
object = object->next) {
llcache_object_notify_users(object);
}
@@ -2415,7 +2415,7 @@ nserror llcache_handle_release(llcache_handle *handle)
assert(user != NULL);
if (user->iterator_target) {
- /* Can't remove / delete user object if it's
+ /* Can't remove / delete user object if it's
* the target of an iterator */
user->queued_for_delete = true;
} else {
@@ -2425,8 +2425,8 @@ nserror llcache_handle_release(llcache_handle *handle)
error = llcache_object_user_destroy(user);
}
}
-
- return error;
+
+ return error;
}
/* See llcache.h for documentation */
@@ -2434,14 +2434,14 @@ nserror llcache_handle_clone(llcache_handle *handle, llcache_handle **result)
{
nserror error;
llcache_object_user *newuser;
-
+
error = llcache_object_user_new(handle->cb, handle->pw, &newuser);
if (error == NSERROR_OK) {
llcache_object_add_user(handle->object, newuser);
newuser->handle->state = handle->state;
*result = newuser->handle;
}
-
+
return error;
}
@@ -2452,13 +2452,13 @@ nserror llcache_handle_abort(llcache_handle *handle)
llcache_object *object = handle->object, *newobject;
nserror error = NSERROR_OK;
bool all_alone = true;
-
+
/* Determine if we are the only user */
if (user->prev != NULL)
all_alone = false;
if (user->next != NULL)
all_alone = false;
-
+
if (all_alone == false) {
/* We must snapshot this object */
error = llcache_object_snapshot(object, &newobject);
@@ -2468,7 +2468,7 @@ nserror llcache_handle_abort(llcache_handle *handle)
/* Move across to the new object */
if (user->iterator_target) {
/* User is current iterator target, clone it */
- llcache_object_user *newuser =
+ llcache_object_user *newuser =
calloc(1, sizeof(llcache_object_user));
if (newuser == NULL) {
llcache_object_destroy(newobject);
@@ -2487,9 +2487,9 @@ nserror llcache_handle_abort(llcache_handle *handle)
llcache_object_remove_user(object, user);
llcache_object_add_user(newobject, user);
}
-
+
/* Add new object to uncached list */
- llcache_object_add_to_list(newobject,
+ llcache_object_add_to_list(newobject,
&llcache->uncached_objects);
} else {
/* We're the only user, so abort any fetch in progress */
@@ -2497,13 +2497,13 @@ nserror llcache_handle_abort(llcache_handle *handle)
fetch_abort(object->fetch.fetch);
object->fetch.fetch = NULL;
}
-
+
object->fetch.state = LLCACHE_FETCH_COMPLETE;
-
+
/* Invalidate cache control data */
llcache_invalidate_cache_control_data(object);
}
-
+
return error;
}
@@ -2519,7 +2519,7 @@ nserror llcache_handle_force_stream(llcache_handle *handle)
/* Forcibly uncache this object */
if (llcache_object_in_list(object, llcache->cached_objects)) {
- llcache_object_remove_from_list(object,
+ llcache_object_remove_from_list(object,
&llcache->cached_objects);
llcache_object_add_to_list(object, &llcache->uncached_objects);
}
@@ -2532,8 +2532,8 @@ nserror llcache_handle_force_stream(llcache_handle *handle)
/* See llcache.h for documentation */
nserror llcache_handle_invalidate_cache_data(llcache_handle *handle)
{
- if (handle->object != NULL && handle->object->fetch.fetch == NULL &&
- handle->object->cache.no_cache ==
+ if (handle->object != NULL && handle->object->fetch.fetch == NULL &&
+ handle->object->cache.no_cache ==
LLCACHE_VALIDATE_FRESH) {
handle->object->cache.no_cache = LLCACHE_VALIDATE_ONCE;
}
@@ -2557,7 +2557,7 @@ const uint8_t *llcache_handle_get_source_data(const llcache_handle *handle,
}
/* See llcache.h for documentation */
-const char *llcache_handle_get_header(const llcache_handle *handle,
+const char *llcache_handle_get_header(const llcache_handle *handle,
const char *key)
{
const llcache_object *object = handle->object;
@@ -2576,9 +2576,8 @@ const char *llcache_handle_get_header(const llcache_handle *handle,
}
/* See llcache.h for documentation */
-bool llcache_handle_references_same_object(const llcache_handle *a,
+bool llcache_handle_references_same_object(const llcache_handle *a,
const llcache_handle *b)
{
return a->object == b->object;
}
-
-----------------------------------------------------------------------
Summary of changes:
content/llcache.c | 343 ++++++++++++++++++++++++-----------------------------
1 files changed, 154 insertions(+), 189 deletions(-)
diff --git a/content/llcache.c b/content/llcache.c
index e4baec6..bd7ae93 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -38,6 +38,12 @@
/** Define to enable tracing of llcache operations. */
#undef LLCACHE_TRACE
+#ifdef LLCACHE_TRACE
+#define LLCACHE_LOG(x) LOG(x)
+#else
+#define LLCACHE_LOG(x)
+#endif
+
/** State of a low-level cache object fetch */
typedef enum {
LLCACHE_FETCH_INIT, /**< Initial state, before fetch */
@@ -75,7 +81,7 @@ typedef struct llcache_object_user {
typedef struct {
uint32_t flags; /**< Fetch flags */
nsurl *referer; /**< Referring URL, or NULL if none */
- llcache_post_data *post; /**< POST data, or NULL for GET */
+ llcache_post_data *post; /**< POST data, or NULL for GET */
struct fetch *fetch; /**< Fetch handle for this object */
@@ -124,7 +130,7 @@ struct llcache_object {
nsurl *url; /**< Post-redirect URL for object */
bool has_query; /**< URL has a query segment */
-
+
/** \todo We need a generic dynamic buffer object */
uint8_t *source_data; /**< Source data for object */
size_t source_len; /**< Byte length of source data */
@@ -137,7 +143,7 @@ struct llcache_object {
llcache_cache_control cache; /**< Cache control data for object */
llcache_object *candidate; /**< Object to use, if fetch determines
* that it is still fresh */
- uint32_t candidate_count; /**< Count of objects this is a
+ uint32_t candidate_count; /**< Count of objects this is a
* candidate for */
llcache_header *headers; /**< Fetch headers */
@@ -200,9 +206,7 @@ static nserror llcache_object_user_new(llcache_handle_callback cb, void *pw,
u->handle = h;
-#ifdef LLCACHE_TRACE
- LOG(("Created user %p (%p, %p, %p)", u, h, (void *) cb, pw));
-#endif
+ LLCACHE_LOG(("Created user %p (%p, %p, %p)", u, h, (void *) cb, pw));
*user = u;
@@ -219,13 +223,11 @@ static nserror llcache_object_user_new(llcache_handle_callback cb, void *pw,
*/
static nserror llcache_object_user_destroy(llcache_object_user *user)
{
-#ifdef LLCACHE_TRACE
- LOG(("Destroyed user %p", user));
-#endif
-
+ LLCACHE_LOG(("Destroyed user %p", user));
+
assert(user->next == NULL);
assert(user->prev == NULL);
-
+
if (user->handle != NULL)
free(user->handle);
@@ -241,7 +243,7 @@ static nserror llcache_object_user_destroy(llcache_object_user *user)
* \param user User to remove
* \return NSERROR_OK.
*/
-static nserror llcache_object_remove_user(llcache_object *object,
+static nserror llcache_object_remove_user(llcache_object *object,
llcache_object_user *user)
{
assert(user != NULL);
@@ -249,7 +251,7 @@ static nserror llcache_object_remove_user(llcache_object *object,
assert(object->users != NULL);
assert(user->handle == NULL || user->handle->object == object);
assert((user->prev != NULL) || (object->users == user));
-
+
if (user == object->users)
object->users = user->next;
else
@@ -257,12 +259,10 @@ static nserror llcache_object_remove_user(llcache_object *object,
if (user->next != NULL)
user->next->prev = user->prev;
-
+
user->next = user->prev = NULL;
-
-#ifdef LLCACHE_TRACE
- LOG(("Removing user %p from %p", user, object));
-#endif
+
+ LLCACHE_LOG(("Removing user %p from %p", user, object));
return NSERROR_OK;
}
@@ -279,7 +279,7 @@ static nserror llcache_send_event_to_users(llcache_object *object,
{
nserror error = NSERROR_OK;
llcache_object_user *user, *next_user;
-
+
user = object->users;
while (user != NULL) {
user->iterator_target = true;
@@ -301,7 +301,7 @@ static nserror llcache_send_event_to_users(llcache_object *object,
user = next_user;
}
-
+
return error;
}
@@ -318,9 +318,7 @@ static nserror llcache_object_new(nsurl *url, llcache_object **result)
if (obj == NULL)
return NSERROR_NOMEM;
-#ifdef LLCACHE_TRACE
- LOG(("Created object %p (%s)", obj, nsurl_access(url)));
-#endif
+ LLCACHE_LOG(("Created object %p (%s)", obj, nsurl_access(url)));
obj->url = nsurl_ref(url);
@@ -336,7 +334,7 @@ static nserror llcache_object_new(nsurl *url, llcache_object **result)
* \param clone Pointer to location to receive clone
* \return NSERROR_OK on success, appropriate error otherwise
*/
-static nserror llcache_post_data_clone(const llcache_post_data *orig,
+static nserror llcache_post_data_clone(const llcache_post_data *orig,
llcache_post_data **clone)
{
llcache_post_data *post_clone;
@@ -379,7 +377,7 @@ static nserror llcache_post_data_clone(const llcache_post_data *orig,
* \param value Pointer to location to receive header value
* \return NSERROR_OK on success, appropriate error otherwise
*/
-static nserror llcache_fetch_split_header(const uint8_t *data, size_t len,
+static nserror llcache_fetch_split_header(const uint8_t *data, size_t len,
char **name, char **value)
{
char *n, *v;
@@ -408,8 +406,8 @@ static nserror llcache_fetch_split_header(const uint8_t *data, size_t len,
}
/* Strip trailing whitespace from name */
- while (colon > data && (colon[-1] == ' ' ||
- colon[-1] == '\t' || colon[-1] == '\r' ||
+ while (colon > data && (colon[-1] == ' ' ||
+ colon[-1] == '\t' || colon[-1] == '\r' ||
colon[-1] == '\n'))
colon--;
@@ -425,12 +423,12 @@ static nserror llcache_fetch_split_header(const uint8_t *data, size_t len,
/* Skip over colon and any subsequent whitespace */
do {
colon++;
- } while (*colon == ' ' || *colon == '\t' ||
+ } while (*colon == ' ' || *colon == '\t' ||
*colon == '\r' || *colon == '\n');
/* Strip trailing whitespace from value */
- while (len > 0 && (data[len - 1] == ' ' ||
- data[len - 1] == '\t' ||
+ while (len > 0 && (data[len - 1] == ' ' ||
+ data[len - 1] == '\t' ||
data[len - 1] == '\r' ||
data[len - 1] == '\n')) {
len--;
@@ -459,11 +457,11 @@ static nserror llcache_fetch_split_header(const uint8_t *data, size_t len,
* \param value Pointer to location to receive header value
* \return NSERROR_OK on success, appropriate error otherwise
*
- * \note This function also has the side-effect of updating
+ * \note This function also has the side-effect of updating
* the cache control data for the object if an interesting
* header is encountered
*/
-static nserror llcache_fetch_parse_header(llcache_object *object,
+static nserror llcache_fetch_parse_header(llcache_object *object,
const uint8_t *data, size_t len, char **name, char **value)
{
nserror error;
@@ -499,13 +497,13 @@ static nserror llcache_fetch_parse_header(llcache_object *object,
while (*comma != '\0' && *comma != ',')
comma++;
- if (8 < comma - start && (strncasecmp(start,
- "no-cache", 8) == 0 ||
+ if (8 < comma - start && (strncasecmp(start,
+ "no-cache", 8) == 0 ||
strncasecmp(start, "no-store", 8) == 0))
/* When we get a disk cache we should
* distinguish between these two */
object->cache.no_cache = LLCACHE_VALIDATE_ALWAYS;
- else if (7 < comma - start &&
+ else if (7 < comma - start &&
strncasecmp(start, "max-age", 7) == 0) {
/* Find '=' */
while (start < comma && *start != '=')
@@ -547,7 +545,7 @@ static nserror llcache_fetch_parse_header(llcache_object *object,
#undef SKIP_ST
- return NSERROR_OK;
+ return NSERROR_OK;
}
/* Destroy headers */
@@ -581,7 +579,7 @@ static inline void llcache_invalidate_cache_control_data(llcache_object *object)
* \param len Byte length of header
* \return NSERROR_OK on success, appropriate error otherwise
*/
-static nserror llcache_fetch_process_header(llcache_object *object,
+static nserror llcache_fetch_process_header(llcache_object *object,
const uint8_t *data, size_t len)
{
nserror error;
@@ -589,14 +587,14 @@ static nserror llcache_fetch_process_header(llcache_object *object,
llcache_header *temp;
/* The headers for multiple HTTP responses may be delivered to us if
- * the fetch layer receives a 401 response for which it has
+ * the fetch layer receives a 401 response for which it has
* authentication credentials. This will result in a silent re-request
* after which we'll receive the actual response headers for the
* object we want to fetch (assuming that the credentials were correct
* of course)
*
- * Therefore, if the header is an HTTP response start marker, then we
- * must discard any headers we've read so far, reset the cache data
+ * Therefore, if the header is an HTTP response start marker, then we
+ * must discard any headers we've read so far, reset the cache data
* that we might have computed, and start again.
*/
/** \todo Properly parse the response line */
@@ -617,7 +615,7 @@ static nserror llcache_fetch_process_header(llcache_object *object,
}
/* Append header data to the object's headers array */
- temp = realloc(object->headers, (object->num_headers + 1) *
+ temp = realloc(object->headers, (object->num_headers + 1) *
sizeof(llcache_header));
if (temp == NULL) {
free(name);
@@ -642,7 +640,7 @@ static nserror llcache_fetch_process_header(llcache_object *object,
* \return NSERROR_OK on success, appropriate error otherwise
*
* \pre The fetch parameters in object->fetch must be populated
- */
+ */
static nserror llcache_object_refetch(llcache_object *object)
{
const char *urlenc = NULL;
@@ -663,7 +661,7 @@ static nserror llcache_object_refetch(llcache_object *object)
return NSERROR_NOMEM;
if (object->cache.etag != NULL) {
- const size_t len = SLEN("If-None-Match: ") +
+ const size_t len = SLEN("If-None-Match: ") +
strlen(object->cache.etag) + 1;
headers[header_idx] = malloc(len);
@@ -703,9 +701,7 @@ static nserror llcache_object_refetch(llcache_object *object)
/* Reset fetch state */
object->fetch.state = LLCACHE_FETCH_INIT;
-#ifdef LLCACHE_TRACE
- LOG(("Refetching %p", object));
-#endif
+ LLCACHE_LOG(("Refetching %p", object));
/* Kick off fetch */
object->fetch.fetch = fetch_start(object->url, object->fetch.referer,
@@ -739,7 +735,7 @@ static nserror llcache_object_refetch(llcache_object *object)
* \return NSERROR_OK on success, appropriate error otherwise
*
* \pre object::url must contain the URL to fetch
- * \pre If there is a freshness validation candidate,
+ * \pre If there is a freshness validation candidate,
* object::candidate and object::cache must be filled in
* \pre There must not be a fetch in progress for \a object
*/
@@ -751,9 +747,7 @@ static nserror llcache_object_fetch(llcache_object *object, uint32_t flags,
nsurl *referer_clone = NULL;
llcache_post_data *post_clone = NULL;
-#ifdef LLCACHE_TRACE
- LOG(("Starting fetch for %p", object));
-#endif
+ LLCACHE_LOG(("Starting fetch for %p", object));
if (post != NULL) {
error = llcache_post_data_clone(post, &post_clone);
@@ -786,9 +780,7 @@ static nserror llcache_object_destroy(llcache_object *object)
{
size_t i;
-#ifdef LLCACHE_TRACE
- LOG(("Destroying object %p", object));
-#endif
+ LLCACHE_LOG(("Destroying object %p", object));
nsurl_unref(object->url);
free(object->source_data);
@@ -872,9 +864,7 @@ llcache_object_rfc2616_remaining_lifetime(const llcache_cache_control *cd)
else
freshness_lifetime = 0;
-#ifdef LLCACHE_TRACE
- LOG(("%d:%d", freshness_lifetime, current_age));
-#endif
+ LLCACHE_LOG(("%d:%d", freshness_lifetime, current_age));
if ((cd->no_cache == LLCACHE_VALIDATE_FRESH) &&
(freshness_lifetime > current_age)) {
@@ -903,17 +893,15 @@ static bool llcache_object_is_fresh(const llcache_object *object)
remaining_lifetime = llcache_object_rfc2616_remaining_lifetime(cd);
-#ifdef LLCACHE_TRACE
- LOG(("%p: (%d > 0 || %d != %d)", object,
+ LLCACHE_LOG(("%p: (%d > 0 || %d != %d)", object,
remaining_lifetime,
object->fetch.state, LLCACHE_FETCH_COMPLETE));
-#endif
/* The object is fresh if:
* - it was not forbidden from being returned from the cache
* unvalidated.
*
- * - it has remaining lifetime or still being fetched.
+ * - it has remaining lifetime or still being fetched.
*/
return ((cd->no_cache == LLCACHE_VALIDATE_FRESH) &&
((remaining_lifetime > 0) ||
@@ -970,7 +958,7 @@ static nserror llcache_object_clone_cache_data(llcache_object *source,
if (source->cache.no_cache != LLCACHE_VALIDATE_FRESH)
destination->cache.no_cache = source->cache.no_cache;
-
+
if (source->cache.last_modified != 0)
destination->cache.last_modified = source->cache.last_modified;
@@ -995,14 +983,13 @@ static nserror llcache_object_retrieve_from_cache(nsurl *url, uint32_t flags,
nserror error;
llcache_object *obj, *newest = NULL;
-#ifdef LLCACHE_TRACE
- LOG(("Searching cache for %s (%x %s %p)", url, flags, referer, post));
-#endif
+ LLCACHE_LOG(("Searching cache for %s (%x %p %p)",
+ nsurl_access(url), flags, referer, post));
/* Search for the most recently fetched matching object */
for (obj = llcache->cached_objects; obj != NULL; obj = obj->next) {
- if ((newest == NULL ||
+ if ((newest == NULL ||
obj->cache.req_time > newest->cache.req_time) &&
nsurl_compare(obj->url, url,
NSURL_COMPLETE) == true) {
@@ -1014,9 +1001,7 @@ static nserror llcache_object_retrieve_from_cache(nsurl *url, uint32_t flags,
/* Found a suitable object, and it's still fresh, so use it */
obj = newest;
-#ifdef LLCACHE_TRACE
- LOG(("Found fresh %p", obj));
-#endif
+ LLCACHE_LOG(("Found fresh %p", obj));
/* The client needs to catch up with the object's state.
* This will occur the next time that llcache_poll is called.
@@ -1029,16 +1014,14 @@ static nserror llcache_object_retrieve_from_cache(nsurl *url, uint32_t flags,
if (error != NSERROR_OK)
return error;
-#ifdef LLCACHE_TRACE
- LOG(("Found candidate %p (%p)", obj, newest));
-#endif
+ LLCACHE_LOG(("Found candidate %p (%p)", obj, newest));
/* Clone candidate's cache data */
error = llcache_object_clone_cache_data(newest, obj, true);
if (error != NSERROR_OK) {
llcache_object_destroy(obj);
return error;
- }
+ }
/* Record candidate, so we can fall back if it is still fresh */
newest->candidate_count++;
@@ -1062,9 +1045,7 @@ static nserror llcache_object_retrieve_from_cache(nsurl *url, uint32_t flags,
if (error != NSERROR_OK)
return error;
-#ifdef LLCACHE_TRACE
- LOG(("Not found %p", obj));
-#endif
+ LLCACHE_LOG(("Not found %p", obj));
/* Attempt to kick-off fetch */
error = llcache_object_fetch(obj, flags, referer, post,
@@ -1103,9 +1084,8 @@ static nserror llcache_object_retrieve(nsurl *url, uint32_t flags,
bool has_query;
nsurl *defragmented_url;
-#ifdef LLCACHE_TRACE
- LOG(("Retrieve %s (%x, %s, %p)", url, flags, referer, post));
-#endif
+ LLCACHE_LOG(("Retrieve %s (%x, %p, %p)",
+ nsurl_access(url), flags, referer, post));
/**
* Caching Rules:
@@ -1135,7 +1115,7 @@ static nserror llcache_object_retrieve(nsurl *url, uint32_t flags,
}
/* Attempt to kick-off fetch */
- error = llcache_object_fetch(obj, flags, referer, post,
+ error = llcache_object_fetch(obj, flags, referer, post,
redirect_count);
if (error != NSERROR_OK) {
llcache_object_destroy(obj);
@@ -1155,17 +1135,15 @@ static nserror llcache_object_retrieve(nsurl *url, uint32_t flags,
/* Returned object is already in the cached list */
}
-
+
obj->has_query = has_query;
-#ifdef LLCACHE_TRACE
- LOG(("Retrieved %p", obj));
-#endif
-
+ LLCACHE_LOG(("Retrieved %p", obj));
+
*result = obj;
-
+
nsurl_unref(defragmented_url);
-
+
return NSERROR_OK;
}
@@ -1192,9 +1170,7 @@ static nserror llcache_object_add_user(llcache_object *object,
object->users->prev = user;
object->users = user;
-#ifdef LLCACHE_TRACE
- LOG(("Adding user %p to %p", user, object));
-#endif
+ LLCACHE_LOG(("Adding user %p to %p", user, object));
return NSERROR_OK;
}
@@ -1225,13 +1201,13 @@ static nserror llcache_fetch_redirect(llcache_object *object, const char *target
/* Abort fetch for this object */
fetch_abort(object->fetch.fetch);
object->fetch.fetch = NULL;
-
+
/* Invalidate the cache control data */
llcache_invalidate_cache_control_data(object);
/* And mark it complete */
object->fetch.state = LLCACHE_FETCH_COMPLETE;
-
+
/* Forcibly stop redirecting if we've followed too many redirects */
#define REDIRECT_LIMIT 10
if (object->fetch.redirect_count > REDIRECT_LIMIT) {
@@ -1239,7 +1215,7 @@ static nserror llcache_fetch_redirect(llcache_object *object, const char *target
event.type = LLCACHE_EVENT_ERROR;
event.data.msg = messages_get("BadRedirect");
-
+
return llcache_send_event_to_users(object, &event);
}
#undef REDIRECT_LIMIT
@@ -1306,7 +1282,7 @@ static nserror llcache_fetch_redirect(llcache_object *object, const char *target
/* Attempt to fetch target URL */
error = llcache_object_retrieve(url, object->fetch.flags,
- object->fetch.referer, post,
+ object->fetch.referer, post,
object->fetch.redirect_count + 1, &dest);
/* No longer require url */
@@ -1326,7 +1302,7 @@ static nserror llcache_fetch_redirect(llcache_object *object, const char *target
/* Dest is now our object */
*replacement = dest;
- return NSERROR_OK;
+ return NSERROR_OK;
}
/**
@@ -1373,14 +1349,14 @@ static nserror llcache_fetch_notmodified(llcache_object *object,
object->candidate->candidate_count--;
/* Clone our cache control data into the candidate */
- llcache_object_clone_cache_data(object, object->candidate,
+ llcache_object_clone_cache_data(object, object->candidate,
false);
/* Bring candidate's cache data up to date */
llcache_object_cache_update(object->candidate);
/* Revert no-cache to normal, if required */
- if (object->candidate->cache.no_cache ==
+ if (object->candidate->cache.no_cache ==
LLCACHE_VALIDATE_ONCE) {
- object->candidate->cache.no_cache =
+ object->candidate->cache.no_cache =
LLCACHE_VALIDATE_FRESH;
}
@@ -1415,7 +1391,7 @@ static nserror llcache_fetch_notmodified(llcache_object *object,
* \param len Byte length of data
* \return NSERROR_OK on success, appropriate error otherwise.
*/
-static nserror llcache_fetch_process_data(llcache_object *object, const uint8_t *data,
+static nserror llcache_fetch_process_data(llcache_object *object, const uint8_t *data,
size_t len)
{
/* Resize source buffer if it's too small */
@@ -1464,7 +1440,7 @@ static nserror llcache_query_handle_response(bool proceed, void *cbpw)
event.type = LLCACHE_EVENT_ERROR;
/** \todo More appropriate error message */
event.data.msg = messages_get("FetchFailed");
-
+
return llcache_send_event_to_users(object, &event);
}
@@ -1511,7 +1487,7 @@ static nserror llcache_fetch_auth(llcache_object *object, const char *realm)
object->fetch.outstanding_query = true;
- error = llcache->query_cb(&query, llcache->query_cb_pw,
+ error = llcache->query_cb(&query, llcache->query_cb_pw,
llcache_query_handle_response, object);
} else {
llcache_event event;
@@ -1523,7 +1499,7 @@ static nserror llcache_fetch_auth(llcache_object *object, const char *realm)
event.type = LLCACHE_EVENT_ERROR;
/** \todo More appropriate error message */
event.data.msg = messages_get("FetchFailed");
-
+
error = llcache_send_event_to_users(object, &event);
}
} else {
@@ -1578,7 +1554,7 @@ static nserror llcache_fetch_cert_error(llcache_object *object,
event.type = LLCACHE_EVENT_ERROR;
/** \todo More appropriate error message */
event.data.msg = messages_get("FetchFailed");
-
+
error = llcache_send_event_to_users(object, &event);
}
@@ -1612,7 +1588,7 @@ static nserror llcache_fetch_ssl_error(llcache_object *object)
event.type = LLCACHE_EVENT_ERROR;
/** \todo More appropriate error message */
event.data.msg = messages_get("FetchFailed");
-
+
error = llcache_send_event_to_users(object, &event);
} else {
/* Flag that we've tried to downgrade, so that if the
@@ -1636,17 +1612,15 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
llcache_object *object = p;
llcache_event event;
-#ifdef LLCACHE_TRACE
- LOG(("Fetch event %d for %p", msg->type, object));
-#endif
+ LLCACHE_LOG(("Fetch event %d for %p", msg->type, object));
switch (msg->type) {
case FETCH_HEADER:
/* Received a fetch header */
object->fetch.state = LLCACHE_FETCH_HEADERS;
- error = llcache_fetch_process_header(object,
- msg->data.header_or_data.buf,
+ error = llcache_fetch_process_header(object,
+ msg->data.header_or_data.buf,
msg->data.header_or_data.len);
break;
@@ -1660,7 +1634,7 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
object->candidate = NULL;
}
- error = llcache_fetch_redirect(object,
+ error = llcache_fetch_redirect(object,
msg->data.redirect, &object);
break;
case FETCH_NOTMODIFIED:
@@ -1672,7 +1646,7 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
case FETCH_DATA:
/* Received some data */
if (object->fetch.state != LLCACHE_FETCH_DATA) {
- /* On entry into this state, check if we need to
+ /* On entry into this state, check if we need to
* invalidate the cache control data. We are guaranteed
* to have received all response headers.
*
@@ -1687,7 +1661,7 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
long http_code = fetch_http_code(object->fetch.fetch);
if ((http_code != 200 && http_code != 203) ||
- (object->has_query &&
+ (object->has_query &&
(object->cache.max_age == INVALID_AGE &&
object->cache.expires == 0))) {
/* Invalidate cache control data */
@@ -1703,7 +1677,7 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
object->fetch.state = LLCACHE_FETCH_DATA;
- error = llcache_fetch_process_data(object,
+ error = llcache_fetch_process_data(object,
msg->data.header_or_data.buf,
msg->data.header_or_data.len);
break;
@@ -1716,7 +1690,7 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
object->fetch.fetch = NULL;
/* Shrink source buffer to required size */
- temp = realloc(object->source_data,
+ temp = realloc(object->source_data,
object->source_len);
/* If source_len is 0, then temp may be NULL */
if (temp != NULL || object->source_len == 0) {
@@ -1748,9 +1722,9 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
event.type = LLCACHE_EVENT_ERROR;
event.data.msg = msg->data.error;
-
+
error = llcache_send_event_to_users(object, &event);
-
+
break;
case FETCH_PROGRESS:
/* Progress update */
@@ -1758,7 +1732,7 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
event.data.msg = msg->data.progress;
error = llcache_send_event_to_users(object, &event);
-
+
break;
/* Events requiring action */
@@ -1782,8 +1756,8 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
object->candidate = NULL;
}
- error = llcache_fetch_cert_error(object,
- msg->data.cert_err.certs,
+ error = llcache_fetch_cert_error(object,
+ msg->data.cert_err.certs,
msg->data.cert_err.num_certs);
break;
case FETCH_SSL_ERR:
@@ -1892,7 +1866,7 @@ static nserror llcache_object_notify_users(llcache_object *object)
#endif
/**
- * State transitions and event emission for users.
+ * State transitions and event emission for users.
* Rows: user state. Cols: object state.
*
* User\Obj INIT HEADERS DATA COMPLETE
@@ -1924,8 +1898,8 @@ static nserror llcache_object_notify_users(llcache_object *object)
user->iterator_target = true;
/* A note on the computation of next_user:
- *
- * Within this loop, we may make a number of calls to
+ *
+ * Within this loop, we may make a number of calls to
* client code. Our contract with clients is that they
* can do whatever they like from within their callback
* handlers. This is so that we limit the pain of
@@ -1936,7 +1910,7 @@ static nserror llcache_object_notify_users(llcache_object *object)
* user list. In the common case, the user they attempt
* to remove is the current iteration target, and we
* already protect against that causing problems here.
- * However, no such protection exists if the client
+ * However, no such protection exists if the client
* attempts to remove other users from this object's
* user list.
*
@@ -1957,13 +1931,13 @@ static nserror llcache_object_notify_users(llcache_object *object)
emitted_notify = true;
}
- LOG(("User %p state: %d Object state: %d",
+ LOG(("User %p state: %d Object state: %d",
user, handle->state, objstate));
}
#endif
/* User: INIT, Obj: HEADERS, DATA, COMPLETE => User->HEADERS */
- if (handle->state == LLCACHE_FETCH_INIT &&
+ if (handle->state == LLCACHE_FETCH_INIT &&
objstate > LLCACHE_FETCH_INIT) {
handle->state = LLCACHE_FETCH_HEADERS;
}
@@ -1991,7 +1965,7 @@ static nserror llcache_object_notify_users(llcache_object *object)
/* User requested replay */
handle->state = LLCACHE_FETCH_HEADERS;
- /* Continue with the next user -- we'll
+ /* Continue with the next user -- we'll
* reemit the event next time round */
user->iterator_target = false;
next_user = user->next;
@@ -2010,15 +1984,15 @@ static nserror llcache_object_notify_users(llcache_object *object)
/* Construct HAD_DATA event */
event.type = LLCACHE_EVENT_HAD_DATA;
- event.data.data.buf =
+ event.data.data.buf =
object->source_data + handle->bytes;
- event.data.data.len =
+ event.data.data.len =
object->source_len - handle->bytes;
/* Update record of last byte emitted */
- if (object->fetch.flags &
+ if (object->fetch.flags &
LLCACHE_RETRIEVE_STREAM_DATA) {
- /* Streaming, so reset to zero to
+ /* Streaming, so reset to zero to
* minimise amount of cached source data.
* Additionally, we don't support replay
* when streaming. */
@@ -2044,7 +2018,7 @@ static nserror llcache_object_notify_users(llcache_object *object)
/* User requested replay */
handle->bytes = orig_handle_read;
- /* Continue with the next user -- we'll
+ /* Continue with the next user -- we'll
* reemit the data next time round */
user->iterator_target = false;
next_user = user->next;
@@ -2077,7 +2051,7 @@ static nserror llcache_object_notify_users(llcache_object *object)
/* User requested replay */
handle->state = LLCACHE_FETCH_DATA;
- /* Continue with the next user -- we'll
+ /* Continue with the next user -- we'll
* reemit the event next time round */
user->iterator_target = false;
next_user = user->next;
@@ -2116,37 +2090,37 @@ static nserror llcache_object_snapshot(llcache_object *object,
{
llcache_object *newobj;
nserror error;
-
+
error = llcache_object_new(object->url, &newobj);
-
+
if (error != NSERROR_OK)
return error;
-
+
newobj->has_query = object->has_query;
newobj->source_alloc = newobj->source_len = object->source_len;
-
+
if (object->source_len > 0) {
newobj->source_data = malloc(newobj->source_alloc);
if (newobj->source_data == NULL) {
llcache_object_destroy(newobj);
return NSERROR_NOMEM;
}
- memcpy(newobj->source_data, object->source_data,
+ memcpy(newobj->source_data, object->source_data,
newobj->source_len);
}
-
+
if (object->num_headers > 0) {
- newobj->headers = calloc(sizeof(llcache_header),
+ newobj->headers = calloc(sizeof(llcache_header),
object->num_headers);
if (newobj->headers == NULL) {
llcache_object_destroy(newobj);
return NSERROR_NOMEM;
}
while (newobj->num_headers < object->num_headers) {
- llcache_header *nh =
+ llcache_header *nh =
&(newobj->headers[newobj->num_headers]);
- llcache_header *oh =
+ llcache_header *oh =
&(object->headers[newobj->num_headers]);
newobj->num_headers += 1;
nh->name = strdup(oh->name);
@@ -2157,11 +2131,11 @@ static nserror llcache_object_snapshot(llcache_object *object,
}
}
}
-
+
newobj->fetch.state = LLCACHE_FETCH_COMPLETE;
-
+
*snapshot = newobj;
-
+
return NSERROR_OK;
}
@@ -2180,12 +2154,10 @@ void llcache_clean(void)
uint32_t llcache_size = 0;
int remaining_lifetime;
-#ifdef LLCACHE_TRACE
- LOG(("Attempting cache clean"));
-#endif
+ LLCACHE_LOG(("Attempting cache clean"));
/* Candidates for cleaning are (in order of priority):
- *
+ *
* 1) Uncacheable objects with no users
* 2) Stale cacheable objects with no users or pending fetches
* 3) Fresh cacheable objects with no users or pending fetches
@@ -2196,14 +2168,13 @@ void llcache_clean(void)
next = object->next;
/* The candidate count of uncacheable objects is always 0 */
- if ((object->users == NULL) &&
+ if ((object->users == NULL) &&
(object->candidate_count == 0) &&
(object->fetch.fetch == NULL) &&
(object->fetch.outstanding_query == false)) {
-#ifdef LLCACHE_TRACE
- LOG(("Found victim %p", object));
-#endif
- llcache_object_remove_from_list(object,
+ LLCACHE_LOG(("Found victim %p", object));
+
+ llcache_object_remove_from_list(object,
&llcache->uncached_objects);
llcache_object_destroy(object);
} else {
@@ -2227,9 +2198,8 @@ void llcache_clean(void)
llcache_size += object->source_len + sizeof(*object);
} else {
/* object is not fresh */
-#ifdef LLCACHE_TRACE
- LOG(("Found stale cacheable object (%p) with no users or pending fetches", object));
-#endif
+ LLCACHE_LOG(("Found stale cacheable object (%p) with no users or pending fetches", object));
+
llcache_object_remove_from_list(object,
&llcache->cached_objects);
llcache_object_destroy(object);
@@ -2243,18 +2213,17 @@ void llcache_clean(void)
* fetches, only if the cache exceeds the configured size.
*/
if (llcache->limit < llcache_size) {
- for (object = llcache->cached_objects; object != NULL;
+ for (object = llcache->cached_objects; object != NULL;
object = next) {
next = object->next;
- if ((object->users == NULL) &&
+ if ((object->users == NULL) &&
(object->candidate_count == 0) &&
(object->fetch.fetch == NULL) &&
(object->fetch.outstanding_query == false)) {
-#ifdef LLCACHE_TRACE
- LOG(("Found victim %p", object));
-#endif
- llcache_size -=
+ LLCACHE_LOG(("Found victim %p", object));
+
+ llcache_size -=
object->source_len + sizeof(*object);
llcache_object_remove_from_list(object,
@@ -2264,14 +2233,11 @@ void llcache_clean(void)
}
}
-#ifdef LLCACHE_TRACE
- LOG(("Size: %u", llcache_size));
-#endif
-
+ LLCACHE_LOG(("Size: %u", llcache_size));
}
/* See llcache.h for documentation */
-nserror
+nserror
llcache_initialise(llcache_query_callback cb, void *pw, uint32_t llcache_limit)
{
llcache = calloc(1, sizeof(struct llcache_s));
@@ -2330,7 +2296,7 @@ void llcache_finalise(void)
}
/* Fetch system has already been destroyed */
- object->fetch.fetch = NULL;
+ object->fetch.fetch = NULL;
llcache_object_destroy(object);
}
@@ -2343,11 +2309,11 @@ void llcache_finalise(void)
nserror llcache_poll(void)
{
llcache_object *object;
-
+
fetch_poll();
-
+
/* Catch new users up with state of objects */
- for (object = llcache->cached_objects; object != NULL;
+ for (object = llcache->cached_objects; object != NULL;
object = object->next) {
llcache_object_notify_users(object);
}
@@ -2415,7 +2381,7 @@ nserror llcache_handle_release(llcache_handle *handle)
assert(user != NULL);
if (user->iterator_target) {
- /* Can't remove / delete user object if it's
+ /* Can't remove / delete user object if it's
* the target of an iterator */
user->queued_for_delete = true;
} else {
@@ -2425,8 +2391,8 @@ nserror llcache_handle_release(llcache_handle *handle)
error = llcache_object_user_destroy(user);
}
}
-
- return error;
+
+ return error;
}
/* See llcache.h for documentation */
@@ -2434,14 +2400,14 @@ nserror llcache_handle_clone(llcache_handle *handle, llcache_handle **result)
{
nserror error;
llcache_object_user *newuser;
-
+
error = llcache_object_user_new(handle->cb, handle->pw, &newuser);
if (error == NSERROR_OK) {
llcache_object_add_user(handle->object, newuser);
newuser->handle->state = handle->state;
*result = newuser->handle;
}
-
+
return error;
}
@@ -2452,13 +2418,13 @@ nserror llcache_handle_abort(llcache_handle *handle)
llcache_object *object = handle->object, *newobject;
nserror error = NSERROR_OK;
bool all_alone = true;
-
+
/* Determine if we are the only user */
if (user->prev != NULL)
all_alone = false;
if (user->next != NULL)
all_alone = false;
-
+
if (all_alone == false) {
/* We must snapshot this object */
error = llcache_object_snapshot(object, &newobject);
@@ -2468,7 +2434,7 @@ nserror llcache_handle_abort(llcache_handle *handle)
/* Move across to the new object */
if (user->iterator_target) {
/* User is current iterator target, clone it */
- llcache_object_user *newuser =
+ llcache_object_user *newuser =
calloc(1, sizeof(llcache_object_user));
if (newuser == NULL) {
llcache_object_destroy(newobject);
@@ -2487,9 +2453,9 @@ nserror llcache_handle_abort(llcache_handle *handle)
llcache_object_remove_user(object, user);
llcache_object_add_user(newobject, user);
}
-
+
/* Add new object to uncached list */
- llcache_object_add_to_list(newobject,
+ llcache_object_add_to_list(newobject,
&llcache->uncached_objects);
} else {
/* We're the only user, so abort any fetch in progress */
@@ -2497,13 +2463,13 @@ nserror llcache_handle_abort(llcache_handle *handle)
fetch_abort(object->fetch.fetch);
object->fetch.fetch = NULL;
}
-
+
object->fetch.state = LLCACHE_FETCH_COMPLETE;
-
+
/* Invalidate cache control data */
llcache_invalidate_cache_control_data(object);
}
-
+
return error;
}
@@ -2519,7 +2485,7 @@ nserror llcache_handle_force_stream(llcache_handle *handle)
/* Forcibly uncache this object */
if (llcache_object_in_list(object, llcache->cached_objects)) {
- llcache_object_remove_from_list(object,
+ llcache_object_remove_from_list(object,
&llcache->cached_objects);
llcache_object_add_to_list(object, &llcache->uncached_objects);
}
@@ -2532,8 +2498,8 @@ nserror llcache_handle_force_stream(llcache_handle *handle)
/* See llcache.h for documentation */
nserror llcache_handle_invalidate_cache_data(llcache_handle *handle)
{
- if (handle->object != NULL && handle->object->fetch.fetch == NULL &&
- handle->object->cache.no_cache ==
+ if (handle->object != NULL && handle->object->fetch.fetch == NULL &&
+ handle->object->cache.no_cache ==
LLCACHE_VALIDATE_FRESH) {
handle->object->cache.no_cache = LLCACHE_VALIDATE_ONCE;
}
@@ -2557,7 +2523,7 @@ const uint8_t *llcache_handle_get_source_data(const llcache_handle *handle,
}
/* See llcache.h for documentation */
-const char *llcache_handle_get_header(const llcache_handle *handle,
+const char *llcache_handle_get_header(const llcache_handle *handle,
const char *key)
{
const llcache_object *object = handle->object;
@@ -2576,9 +2542,8 @@ const char *llcache_handle_get_header(const llcache_handle *handle,
}
/* See llcache.h for documentation */
-bool llcache_handle_references_same_object(const llcache_handle *a,
+bool llcache_handle_references_same_object(const llcache_handle *a,
const llcache_handle *b)
{
return a->object == b->object;
}
-
--
NetSurf Browser
8 years, 11 months
netsurf: branch master updated. release/3.0-1132-g4591b65
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/4591b65ad9003797e6af4...
...commit http://git.netsurf-browser.org/netsurf.git/commit/4591b65ad9003797e6af477...
...tree http://git.netsurf-browser.org/netsurf.git/tree/4591b65ad9003797e6af477ed...
The branch, master has been updated
via 4591b65ad9003797e6af477ed84cc2279a661b91 (commit)
from 69b61198f28a510eba34eca747e8d5eacfee4a0a (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=4591b65ad9003797e6a...
commit 4591b65ad9003797e6af477ed84cc2279a661b91
Author: François Revol <revol(a)free.fr>
Commit: François Revol <revol(a)free.fr>
beos: Fix build
One replacement was missed when changing browser_window_history_forward().
diff --git a/beos/scaffolding.cpp b/beos/scaffolding.cpp
index f2ede25..fa9549c 100644
--- a/beos/scaffolding.cpp
+++ b/beos/scaffolding.cpp
@@ -983,7 +983,7 @@ void nsbeos_scaffolding_dispatch_event(nsbeos_scaffolding *scaffold, BMessage *m
case 'forw':
if (!browser_window_history_forward_available(bw))
break;
- browser_window_history_forward(bw->history, false);
+ browser_window_history_forward(bw, false);
nsbeos_window_update_back_forward(scaffold);
break;
case B_NETPOSITIVE_STOP:
-----------------------------------------------------------------------
Summary of changes:
beos/scaffolding.cpp | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/beos/scaffolding.cpp b/beos/scaffolding.cpp
index f2ede25..fa9549c 100644
--- a/beos/scaffolding.cpp
+++ b/beos/scaffolding.cpp
@@ -983,7 +983,7 @@ void nsbeos_scaffolding_dispatch_event(nsbeos_scaffolding *scaffold, BMessage *m
case 'forw':
if (!browser_window_history_forward_available(bw))
break;
- browser_window_history_forward(bw->history, false);
+ browser_window_history_forward(bw, false);
nsbeos_window_update_back_forward(scaffold);
break;
case B_NETPOSITIVE_STOP:
--
NetSurf Browser
8 years, 11 months
netsurf: branch vince/disccache updated. release/3.0-1134-g4a9b645
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/4a9b6452d488b9778b5d2...
...commit http://git.netsurf-browser.org/netsurf.git/commit/4a9b6452d488b9778b5d2c9...
...tree http://git.netsurf-browser.org/netsurf.git/tree/4a9b6452d488b9778b5d2c980...
The branch, vince/disccache has been updated
via 4a9b6452d488b9778b5d2c98038aea61daadfb79 (commit)
from f058f3711bb3df4b13c73ab8943015cd6485aa9b (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=4a9b6452d488b9778b5...
commit 4a9b6452d488b9778b5d2c98038aea61daadfb79
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
improve comments on control parameters and ensure backing store invalidata gets called when an object becomes stale
diff --git a/content/llcache.c b/content/llcache.c
index 2bcc37b..004034c 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -24,7 +24,7 @@
* store to extend their lifetime.
*
* \todo fix writeout conditions and ordering
- * \todo implement expiry from backing store
+ * \todo implement expiry from backing store of objects not currently in cache lists
* \todo make the reference backing store have an index to improve performance
* \todo make the reference backing store have a more efficient metadata store.
* \todo make the reference backing store cope with filesystems that have filename length limits and directory entry count limits
@@ -2012,6 +2012,26 @@ overflow:
}
/**
+ * construct a sorted list of objects available for writeout operation
+ *
+ * The list contains fresh cacheable objects held in RAM with no
+ * pending fetches. Any objects with a remaining lifetime less than
+ * LLCACHE_MIN_DISC_LIFETIME time are simply not considered, they will
+ * become stale before pushing to backing store is worth the cost.
+ *
+ * The list is sorted by object size, largest first
+ *
+ * \todo calculate useful cost metrics to improve sorting
+ *
+ */
+#if 0
+static struct llcache_object**
+build_candidate_list()
+{
+}
+#endif
+
+/**
* possibly push objects data to persiatant storage.
*/
static void llcache_persist(void *p)
@@ -2546,8 +2566,8 @@ static nserror llcache_object_notify_users(llcache_object *object)
* \param snapshot Pointer to receive snapshot of \a object
* \return NSERROR_OK on success, appropriate error otherwise
*/
-static nserror llcache_object_snapshot(llcache_object *object,
- llcache_object **snapshot)
+static nserror
+llcache_object_snapshot(llcache_object *object, llcache_object **snapshot)
{
llcache_object *newobj;
nserror error;
@@ -2600,22 +2620,6 @@ static nserror llcache_object_snapshot(llcache_object *object,
return NSERROR_OK;
}
-/**
- * construct a sorted list of objects available for cleaning operations
- *
- * The list contains fresh cacheable objects with no users or pending
- * fetches. Any objects with a remaining lifetime less than cache poll
- * time are simply not considered, they will become stale before the
- * next cache poll and removed.
- *
- * The list is sorted by:
- */
-/*static struct victim_list*
-build_candidate_list()
-{
-}
-*/
-
/******************************************************************************
* Public API *
******************************************************************************/
@@ -2679,6 +2683,11 @@ void llcache_clean(void)
llcache_object_remove_from_list(object,
&llcache->cached_objects);
+
+ if (object->store_state == LLCACHE_STORE_DISC) {
+ guit->llcache->invalidate(object->url);
+ }
+
llcache_object_destroy(object);
}
} else {
@@ -2689,7 +2698,8 @@ void llcache_clean(void)
/* if the cache limit is exceeded try to make some objects
* persistant so their RAM can be reclaimed in the next
- * step */
+ * step
+ */
if (llcache->limit < llcache_size) {
llcache_persist(NULL);
}
diff --git a/desktop/netsurf.c b/desktop/netsurf.c
index 67ae868..582c119 100644
--- a/desktop/netsurf.c
+++ b/desktop/netsurf.c
@@ -67,11 +67,17 @@
*/
#define SPECULATE_SMALL 4096
-/* the time between cache clean runs in ms */
+/** the time between image cache clean runs in ms */
#define IMAGE_CACHE_CLEAN_TIME (10 * 1000)
+/** default time between content cache cleans */
#define HL_CACHE_CLEAN_TIME (2 * IMAGE_CACHE_CLEAN_TIME)
+/** ensure there is a minimal amount of memory for source objetcs and
+ * decoded bitmaps.
+ */
+#define MINIMUM_MEMORY_CACHE_SIZE (2 * 1024 * 1024)
+
bool netsurf_quit = false;
static void netsurf_lwc_iterator(lwc_string *str, void *pw)
@@ -108,8 +114,6 @@ static nserror netsurf_llcache_query_handler(const llcache_query *query,
return NSERROR_OK;
}
-#define MINIMUM_MEMORY_CACHE_SIZE (2 * 1024 * 1024)
-
/**
* Initialise components used by gui NetSurf.
*/
-----------------------------------------------------------------------
Summary of changes:
content/llcache.c | 50 ++++++++++++++++++++++++++++++--------------------
desktop/netsurf.c | 10 +++++++---
2 files changed, 37 insertions(+), 23 deletions(-)
diff --git a/content/llcache.c b/content/llcache.c
index 2bcc37b..004034c 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -24,7 +24,7 @@
* store to extend their lifetime.
*
* \todo fix writeout conditions and ordering
- * \todo implement expiry from backing store
+ * \todo implement expiry from backing store of objects not currently in cache lists
* \todo make the reference backing store have an index to improve performance
* \todo make the reference backing store have a more efficient metadata store.
* \todo make the reference backing store cope with filesystems that have filename length limits and directory entry count limits
@@ -2012,6 +2012,26 @@ overflow:
}
/**
+ * construct a sorted list of objects available for writeout operation
+ *
+ * The list contains fresh cacheable objects held in RAM with no
+ * pending fetches. Any objects with a remaining lifetime less than
+ * LLCACHE_MIN_DISC_LIFETIME time are simply not considered, they will
+ * become stale before pushing to backing store is worth the cost.
+ *
+ * The list is sorted by object size, largest first
+ *
+ * \todo calculate useful cost metrics to improve sorting
+ *
+ */
+#if 0
+static struct llcache_object**
+build_candidate_list()
+{
+}
+#endif
+
+/**
* possibly push objects data to persiatant storage.
*/
static void llcache_persist(void *p)
@@ -2546,8 +2566,8 @@ static nserror llcache_object_notify_users(llcache_object *object)
* \param snapshot Pointer to receive snapshot of \a object
* \return NSERROR_OK on success, appropriate error otherwise
*/
-static nserror llcache_object_snapshot(llcache_object *object,
- llcache_object **snapshot)
+static nserror
+llcache_object_snapshot(llcache_object *object, llcache_object **snapshot)
{
llcache_object *newobj;
nserror error;
@@ -2600,22 +2620,6 @@ static nserror llcache_object_snapshot(llcache_object *object,
return NSERROR_OK;
}
-/**
- * construct a sorted list of objects available for cleaning operations
- *
- * The list contains fresh cacheable objects with no users or pending
- * fetches. Any objects with a remaining lifetime less than cache poll
- * time are simply not considered, they will become stale before the
- * next cache poll and removed.
- *
- * The list is sorted by:
- */
-/*static struct victim_list*
-build_candidate_list()
-{
-}
-*/
-
/******************************************************************************
* Public API *
******************************************************************************/
@@ -2679,6 +2683,11 @@ void llcache_clean(void)
llcache_object_remove_from_list(object,
&llcache->cached_objects);
+
+ if (object->store_state == LLCACHE_STORE_DISC) {
+ guit->llcache->invalidate(object->url);
+ }
+
llcache_object_destroy(object);
}
} else {
@@ -2689,7 +2698,8 @@ void llcache_clean(void)
/* if the cache limit is exceeded try to make some objects
* persistant so their RAM can be reclaimed in the next
- * step */
+ * step
+ */
if (llcache->limit < llcache_size) {
llcache_persist(NULL);
}
diff --git a/desktop/netsurf.c b/desktop/netsurf.c
index 67ae868..582c119 100644
--- a/desktop/netsurf.c
+++ b/desktop/netsurf.c
@@ -67,11 +67,17 @@
*/
#define SPECULATE_SMALL 4096
-/* the time between cache clean runs in ms */
+/** the time between image cache clean runs in ms */
#define IMAGE_CACHE_CLEAN_TIME (10 * 1000)
+/** default time between content cache cleans */
#define HL_CACHE_CLEAN_TIME (2 * IMAGE_CACHE_CLEAN_TIME)
+/** ensure there is a minimal amount of memory for source objetcs and
+ * decoded bitmaps.
+ */
+#define MINIMUM_MEMORY_CACHE_SIZE (2 * 1024 * 1024)
+
bool netsurf_quit = false;
static void netsurf_lwc_iterator(lwc_string *str, void *pw)
@@ -108,8 +114,6 @@ static nserror netsurf_llcache_query_handler(const llcache_query *query,
return NSERROR_OK;
}
-#define MINIMUM_MEMORY_CACHE_SIZE (2 * 1024 * 1024)
-
/**
* Initialise components used by gui NetSurf.
*/
--
NetSurf Browser
8 years, 11 months
netsurf: branch vince/disccache updated. release/3.0-1133-gf058f37
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/f058f3711bb3df4b13c73...
...commit http://git.netsurf-browser.org/netsurf.git/commit/f058f3711bb3df4b13c73ab...
...tree http://git.netsurf-browser.org/netsurf.git/tree/f058f3711bb3df4b13c73ab89...
The branch, vince/disccache has been updated
via f058f3711bb3df4b13c73ab8943015cd6485aa9b (commit)
from ab1a76ee8ab178cc52050c1e29a28775a0a6636d (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=f058f3711bb3df4b13c...
commit f058f3711bb3df4b13c73ab8943015cd6485aa9b
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
allow initialisation, finalisation and configutarion of the backing store
diff --git a/content/hlcache.c b/content/hlcache.c
index 6e646c8..6595462 100644
--- a/content/hlcache.c
+++ b/content/hlcache.c
@@ -525,9 +525,7 @@ hlcache_initialise(const struct hlcache_parameters *hlcache_parameters)
return NSERROR_NOMEM;
}
- ret = llcache_initialise(hlcache_parameters->cb,
- hlcache_parameters->cb_ctx,
- hlcache_parameters->limit);
+ ret = llcache_initialise(&hlcache_parameters->llcache);
if (ret != NSERROR_OK) {
free(hlcache);
hlcache = NULL;
diff --git a/content/hlcache.h b/content/hlcache.h
index 41f1ed6..746b3c8 100644
--- a/content/hlcache.h
+++ b/content/hlcache.h
@@ -23,11 +23,12 @@
#ifndef NETSURF_CONTENT_HLCACHE_H_
#define NETSURF_CONTENT_HLCACHE_H_
-#include "content/content.h"
-#include "content/llcache.h"
#include "utils/errors.h"
#include "utils/nsurl.h"
+#include "content/content.h"
+#include "content/llcache.h"
+
/** High-level cache handle */
typedef struct hlcache_handle hlcache_handle;
@@ -44,18 +45,10 @@ typedef struct {
} hlcache_event;
struct hlcache_parameters {
- llcache_query_callback cb; /**< Query handler for llcache */
- void *cb_ctx; /**< Pointer to llcache query handler data */
-
/** How frequently the background cache clean process is run (ms) */
unsigned int bg_clean_time;
- /** The target upper bound for the cache size */
- size_t limit;
-
- /** The hysteresis allowed round the target size */
- size_t hysteresis;
-
+ struct llcache_parameters llcache;
};
/**
@@ -67,13 +60,13 @@ struct hlcache_parameters {
* \return NSERROR_OK on success, appropriate error otherwise.
*/
typedef nserror (*hlcache_handle_callback)(hlcache_handle *handle,
- const hlcache_event *event, void *pw);
+ const hlcache_event *event, void *pw);
/** Flags for high-level cache object retrieval */
enum hlcache_retrieve_flag {
- /* Note: low-level cache retrieval flags occupy the bottom 16 bits of
- * the flags word. High-level cache flags occupy the top 16 bits.
- * To avoid confusion, high-level flags are allocated from bit 31 down.
+ /* Note: low-level cache retrieval flags occupy the bottom 16 bits of
+ * the flags word. High-level cache flags occupy the top 16 bits.
+ * To avoid confusion, high-level flags are allocated from bit 31 down.
*/
/** It's permitted to convert this request into a download */
HLCACHE_RETRIEVE_MAY_DOWNLOAD = (1 << 31),
@@ -84,7 +77,7 @@ enum hlcache_retrieve_flag {
/**
* Initialise the high-level cache, preparing the llcache also.
*
- * \param hlcache_parameters Settings to initialise cache with
+ * \param hlcache_parameters Settings to initialise cache with
* \return NSERROR_OK on success, appropriate error otherwise.
*/
nserror hlcache_initialise(const struct hlcache_parameters *hlcache_parameters);
@@ -133,7 +126,7 @@ nserror hlcache_poll(void);
nserror hlcache_handle_retrieve(nsurl *url, uint32_t flags,
nsurl *referer, llcache_post_data *post,
hlcache_handle_callback cb, void *pw,
- hlcache_child_context *child,
+ hlcache_child_context *child,
content_type accepted_types, hlcache_handle **result);
/**
@@ -169,13 +162,13 @@ nserror hlcache_handle_replace_callback(hlcache_handle *handle,
* \param handle Cache handle to dereference
* \return Pointer to content object, or NULL if there is none
*
- * \todo This may not be correct. Ideally, the client should never need to
- * directly access a content object. It may, therefore, be better to provide a
- * bunch of veneers here that take a hlcache_handle and invoke the
+ * \todo This may not be correct. Ideally, the client should never need to
+ * directly access a content object. It may, therefore, be better to provide a
+ * bunch of veneers here that take a hlcache_handle and invoke the
* corresponding content_ API. If there's no content object associated with the
- * hlcache_handle (e.g. because the source data is still being fetched, so it
- * doesn't exist yet), then these veneers would behave as a NOP. The important
- * thing being that the client need not care about this possibility and can
+ * hlcache_handle (e.g. because the source data is still being fetched, so it
+ * doesn't exist yet), then these veneers would behave as a NOP. The important
+ * thing being that the client need not care about this possibility and can
* just call the functions with impugnity.
*/
struct content *hlcache_handle_get_content(const hlcache_handle *handle);
diff --git a/content/llcache.c b/content/llcache.c
index fa886be..2bcc37b 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -24,7 +24,6 @@
* store to extend their lifetime.
*
* \todo fix writeout conditions and ordering
- * \todo add backing store initialisation to set storage parameters like location and size limits.
* \todo implement expiry from backing store
* \todo make the reference backing store have an index to improve performance
* \todo make the reference backing store have a more efficient metadata store.
@@ -2749,20 +2748,21 @@ void llcache_clean(void)
/* See llcache.h for documentation */
nserror
-llcache_initialise(llcache_query_callback cb, void *pw, uint32_t llcache_limit)
+llcache_initialise(const struct llcache_parameters *prm)
{
llcache = calloc(1, sizeof(struct llcache_s));
if (llcache == NULL) {
return NSERROR_NOMEM;
}
- llcache->query_cb = cb;
- llcache->query_cb_pw = pw;
- llcache->limit = llcache_limit;
+ llcache->query_cb = prm->cb;
+ llcache->query_cb_pw = prm->cb_ctx;
+ llcache->limit = prm->limit;
- LOG(("llcache initialised with a limit of %d bytes", llcache_limit));
+ LOG(("llcache initialised with a limit of %d bytes", llcache->limit));
- return NSERROR_OK;
+ /* backing store initialisation */
+ return guit->llcache->initialise(&prm->store);
}
/* See llcache.h for documentation */
@@ -2812,6 +2812,9 @@ void llcache_finalise(void)
llcache_object_destroy(object);
}
+ /* backing store finalisation */
+ guit->llcache->finalise();
+
free(llcache);
llcache = NULL;
}
diff --git a/content/llcache.h b/content/llcache.h
index 3d8232c..6f12c48 100644
--- a/content/llcache.h
+++ b/content/llcache.h
@@ -76,7 +76,7 @@ typedef struct {
} data; /**< Event data */
} llcache_event;
-/**
+/**
* Client callback for low-level cache events
*
* \param handle Handle for which event is issued
@@ -84,18 +84,18 @@ typedef struct {
* \param pw Pointer to client-specific data
* \return NSERROR_OK on success, appropriate error otherwise.
*/
-typedef nserror (*llcache_handle_callback)(llcache_handle *handle,
+typedef nserror (*llcache_handle_callback)(llcache_handle *handle,
const llcache_event *event, void *pw);
/** Flags for low-level cache object retrieval */
enum llcache_retrieve_flag {
/* Note: We're permitted a maximum of 16 flags which must reside in the
- * bottom 16 bits of the flags word. See hlcache.h for further details.
+ * bottom 16 bits of the flags word. See hlcache.h for further details.
*/
/** Force a new fetch */
- LLCACHE_RETRIEVE_FORCE_FETCH = (1 << 0),
+ LLCACHE_RETRIEVE_FORCE_FETCH = (1 << 0),
/** Requested URL was verified */
- LLCACHE_RETRIEVE_VERIFIABLE = (1 << 1),
+ LLCACHE_RETRIEVE_VERIFIABLE = (1 << 1),
/**< No error pages */
LLCACHE_RETRIEVE_NO_ERROR_PAGES = (1 << 2),
/**< Stream data (implies that object is not cacheable) */
@@ -149,21 +149,44 @@ typedef nserror (*llcache_query_response)(bool proceed, void *cbpw);
* \param cbpw Opaque value to pass into \a cb
* \return NSERROR_OK on success, appropriate error otherwise
*
- * \note This callback should return immediately. Once a suitable answer to
- * the query has been obtained, the provided response callback should be
+ * \note This callback should return immediately. Once a suitable answer to
+ * the query has been obtained, the provided response callback should be
* called. This is intended to be an entirely asynchronous process.
*/
typedef nserror (*llcache_query_callback)(const llcache_query *query, void *pw,
llcache_query_response cb, void *cbpw);
/**
+ * Parameters to configure the low level cache backing store.
+ */
+struct llcache_store_parameters {
+ const char *path; /**< The path to the backing store */
+
+ size_t limit; /**< The backing store upper bound target size */
+ size_t hysteresis; /**< The hysteresis around the target size */
+};
+
+/**
+ * Parameters to configure the low level cache.
+ */
+struct llcache_parameters {
+ llcache_query_callback cb; /**< Query handler for llcache */
+ void *cb_ctx; /**< Pointer to llcache query handler data */
+
+ size_t limit; /**< The target upper bound for the RAM cache size */
+ size_t hysteresis; /**< The hysteresis around the target size */
+
+ struct llcache_store_parameters store;
+};
+
+/**
* Initialise the low-level cache
*
* \param cb Query handler
* \param pw Pointer to query handler data
* \return NSERROR_OK on success, appropriate error otherwise.
*/
-nserror llcache_initialise(llcache_query_callback cb, void *pw, uint32_t llcache_limit);
+nserror llcache_initialise(const struct llcache_parameters *parameters);
/**
* Finalise the low-level cache
@@ -280,12 +303,12 @@ const uint8_t *llcache_handle_get_source_data(const llcache_handle *handle,
* \return Header value, or NULL if header does not exist
*
* \todo Make the key an enumeration, to avoid needless string comparisons
- * \todo Forcing the client to parse the header value seems wrong.
- * Better would be to return the actual value part and an array of
+ * \todo Forcing the client to parse the header value seems wrong.
+ * Better would be to return the actual value part and an array of
* key-value pairs for any additional parameters.
* \todo Deal with multiple headers of the same key (e.g. Set-Cookie)
*/
-const char *llcache_handle_get_header(const llcache_handle *handle,
+const char *llcache_handle_get_header(const llcache_handle *handle,
const char *key);
/**
@@ -295,7 +318,7 @@ const char *llcache_handle_get_header(const llcache_handle *handle,
* \param b Second handle
* \return True if handles reference the same object, false otherwise
*/
-bool llcache_handle_references_same_object(const llcache_handle *a,
+bool llcache_handle_references_same_object(const llcache_handle *a,
const llcache_handle *b);
#endif
diff --git a/content/llcache_private.h b/content/llcache_private.h
index f038c9d..dc6cb86 100644
--- a/content/llcache_private.h
+++ b/content/llcache_private.h
@@ -25,13 +25,19 @@
#include "content/llcache.h"
-/** low level cache operation table
+/** low level cache backing store operation table
*
* The low level cache (source objects) has the capability to make
* objects and their metadata (headers etc) persistant by writing to a
* backing store using these operations.
*/
struct gui_llcache_table {
+ /** Initialise the backing store. */
+ nserror (*initialise)(const struct llcache_store_parameters *parameters);
+
+ /** Finalise the backing store. */
+ nserror (*finalise)(void);
+
/** Place a source object and its metadata in the backing store. */
nserror (*store)(struct nsurl *url,
const uint8_t *metadata, const size_t metadatalen,
diff --git a/desktop/gui_factory.c b/desktop/gui_factory.c
index 71fb226..3a33f51 100644
--- a/desktop/gui_factory.c
+++ b/desktop/gui_factory.c
@@ -346,6 +346,18 @@ static nserror verify_utf8_register(struct gui_utf8_table *gut)
}
static nserror
+gui_default_initialise(const struct llcache_store_parameters *parameters)
+{
+ return NSERROR_OK;
+}
+
+static nserror
+gui_default_finalise(void)
+{
+ return NSERROR_OK;
+}
+
+static nserror
gui_default_store(nsurl *url,
const uint8_t *metadata, const size_t metadatalen,
const uint8_t *data, const size_t datalen)
@@ -373,6 +385,8 @@ gui_default_invalidate(nsurl *url)
static struct gui_llcache_table default_llcache_table = {
+ .initialise = gui_default_initialise,
+ .finalise = gui_default_finalise,
.store = gui_default_store,
.fetch = gui_default_fetch,
.meta = gui_default_meta,
@@ -400,6 +414,15 @@ static nserror verify_llcache_register(struct gui_llcache_table *glt)
if (glt->invalidate == NULL) {
return NSERROR_BAD_PARAMETER;
}
+
+ /* fill in the optional entries with defaults */
+ if (glt->initialise == NULL) {
+ glt->initialise = gui_default_initialise;
+ }
+ if (glt->finalise == NULL) {
+ glt->finalise = gui_default_finalise;
+ }
+
return NSERROR_OK;
}
diff --git a/desktop/netsurf.c b/desktop/netsurf.c
index c3653b5..67ae868 100644
--- a/desktop/netsurf.c
+++ b/desktop/netsurf.c
@@ -116,12 +116,13 @@ static nserror netsurf_llcache_query_handler(const llcache_query *query,
nserror netsurf_init(const char *messages, struct gui_table *gt)
{
- nserror error;
+ nserror ret;
struct utsname utsname;
- nserror ret = NSERROR_OK;
struct hlcache_parameters hlcache_parameters = {
.bg_clean_time = HL_CACHE_CLEAN_TIME,
- .cb = netsurf_llcache_query_handler,
+ .llcache = {
+ .cb = netsurf_llcache_query_handler,
+ }
};
struct image_cache_parameters image_cache_parameters = {
.bg_clean_time = IMAGE_CACHE_CLEAN_TIME,
@@ -149,82 +150,94 @@ nserror netsurf_init(const char *messages, struct gui_table *gt)
utsname.version, utsname.machine));
/* register the gui handlers */
- error = gui_factory_register(gt);
- if (error != NSERROR_OK)
- return error;
+ ret = gui_factory_register(gt);
+ if (ret != NSERROR_OK)
+ return ret;
messages_load(messages);
/* corestrings init */
- error = corestrings_init();
- if (error != NSERROR_OK)
- return error;
+ ret = corestrings_init();
+ if (ret != NSERROR_OK)
+ return ret;
/* set up cache limits based on the memory cache size option */
- hlcache_parameters.limit = nsoption_int(memory_cache_size);
+ hlcache_parameters.llcache.limit = nsoption_int(memory_cache_size);
- if (hlcache_parameters.limit < MINIMUM_MEMORY_CACHE_SIZE) {
- hlcache_parameters.limit = MINIMUM_MEMORY_CACHE_SIZE;
- LOG(("Setting minimum memory cache size to %d",
- hlcache_parameters.limit));
+ if (hlcache_parameters.llcache.limit < MINIMUM_MEMORY_CACHE_SIZE) {
+ hlcache_parameters.llcache.limit = MINIMUM_MEMORY_CACHE_SIZE;
+ LOG(("Setting minimum memory cache size %d",
+ hlcache_parameters.llcache.limit));
}
/* image cache is 25% of total memory cache size */
- image_cache_parameters.limit = (hlcache_parameters.limit * 25) / 100;
+ image_cache_parameters.limit = (hlcache_parameters.llcache.limit * 25) / 100;
/* image cache hysteresis is 20% of the image cache size */
image_cache_parameters.hysteresis = (image_cache_parameters.limit * 20) / 100;
/* account for image cache use from total */
- hlcache_parameters.limit -= image_cache_parameters.limit;
+ hlcache_parameters.llcache.limit -= image_cache_parameters.limit;
+
+ /* set backing store target limit */
+ hlcache_parameters.llcache.store.limit = nsoption_int(disc_cache_size);
+
+ /* set backing store hysterissi to 20% */
+ hlcache_parameters.llcache.store.hysteresis = (hlcache_parameters.llcache.store.limit * 20) / 100;;
+
+ /* set the path to the backing store */
+ /** \todo set the backing store path properly */
+ hlcache_parameters.llcache.store.path = "/tmp/ns/";
/* image handler bitmap cache */
- error = image_cache_init(&image_cache_parameters);
- if (error != NSERROR_OK)
- return error;
+ ret = image_cache_init(&image_cache_parameters);
+ if (ret != NSERROR_OK)
+ return ret;
/* content handler initialisation */
- error = nscss_init();
- if (error != NSERROR_OK)
- return error;
+ ret = nscss_init();
+ if (ret != NSERROR_OK)
+ return ret;
- error = html_init();
- if (error != NSERROR_OK)
- return error;
+ ret = html_init();
+ if (ret != NSERROR_OK)
+ return ret;
- error = image_init();
- if (error != NSERROR_OK)
- return error;
+ ret = image_init();
+ if (ret != NSERROR_OK)
+ return ret;
- error = textplain_init();
- if (error != NSERROR_OK)
- return error;
+ ret = textplain_init();
+ if (ret != NSERROR_OK)
+ return ret;
- error = mimesniff_init();
- if (error != NSERROR_OK)
- return error;
+ ret = mimesniff_init();
+ if (ret != NSERROR_OK)
+ return ret;
url_init();
setlocale(LC_ALL, "C");
/* initialise the fetchers */
- error = fetch_init();
- if (error != NSERROR_OK)
- return error;
+ ret = fetch_init();
+ if (ret != NSERROR_OK)
+ return ret;
/* Initialise the hlcache and allow it to init the llcache for us */
- hlcache_initialise(&hlcache_parameters);
+ ret = hlcache_initialise(&hlcache_parameters);
+ if (ret != NSERROR_OK)
+ return ret;
/* Initialize system colours */
- error = ns_system_colour_init();
- if (error != NSERROR_OK)
- return error;
+ ret = ns_system_colour_init();
+ if (ret != NSERROR_OK)
+ return ret;
js_initialise();
- return ret;
+ return NSERROR_OK;
}
-----------------------------------------------------------------------
Summary of changes:
content/hlcache.c | 4 +-
content/hlcache.h | 39 +++++++-----------
content/llcache.c | 17 +++++---
content/llcache.h | 47 ++++++++++++++++------
content/llcache_private.h | 8 +++-
desktop/gui_factory.c | 23 +++++++++++
desktop/netsurf.c | 97 +++++++++++++++++++++++++-------------------
7 files changed, 147 insertions(+), 88 deletions(-)
diff --git a/content/hlcache.c b/content/hlcache.c
index 6e646c8..6595462 100644
--- a/content/hlcache.c
+++ b/content/hlcache.c
@@ -525,9 +525,7 @@ hlcache_initialise(const struct hlcache_parameters *hlcache_parameters)
return NSERROR_NOMEM;
}
- ret = llcache_initialise(hlcache_parameters->cb,
- hlcache_parameters->cb_ctx,
- hlcache_parameters->limit);
+ ret = llcache_initialise(&hlcache_parameters->llcache);
if (ret != NSERROR_OK) {
free(hlcache);
hlcache = NULL;
diff --git a/content/hlcache.h b/content/hlcache.h
index 41f1ed6..746b3c8 100644
--- a/content/hlcache.h
+++ b/content/hlcache.h
@@ -23,11 +23,12 @@
#ifndef NETSURF_CONTENT_HLCACHE_H_
#define NETSURF_CONTENT_HLCACHE_H_
-#include "content/content.h"
-#include "content/llcache.h"
#include "utils/errors.h"
#include "utils/nsurl.h"
+#include "content/content.h"
+#include "content/llcache.h"
+
/** High-level cache handle */
typedef struct hlcache_handle hlcache_handle;
@@ -44,18 +45,10 @@ typedef struct {
} hlcache_event;
struct hlcache_parameters {
- llcache_query_callback cb; /**< Query handler for llcache */
- void *cb_ctx; /**< Pointer to llcache query handler data */
-
/** How frequently the background cache clean process is run (ms) */
unsigned int bg_clean_time;
- /** The target upper bound for the cache size */
- size_t limit;
-
- /** The hysteresis allowed round the target size */
- size_t hysteresis;
-
+ struct llcache_parameters llcache;
};
/**
@@ -67,13 +60,13 @@ struct hlcache_parameters {
* \return NSERROR_OK on success, appropriate error otherwise.
*/
typedef nserror (*hlcache_handle_callback)(hlcache_handle *handle,
- const hlcache_event *event, void *pw);
+ const hlcache_event *event, void *pw);
/** Flags for high-level cache object retrieval */
enum hlcache_retrieve_flag {
- /* Note: low-level cache retrieval flags occupy the bottom 16 bits of
- * the flags word. High-level cache flags occupy the top 16 bits.
- * To avoid confusion, high-level flags are allocated from bit 31 down.
+ /* Note: low-level cache retrieval flags occupy the bottom 16 bits of
+ * the flags word. High-level cache flags occupy the top 16 bits.
+ * To avoid confusion, high-level flags are allocated from bit 31 down.
*/
/** It's permitted to convert this request into a download */
HLCACHE_RETRIEVE_MAY_DOWNLOAD = (1 << 31),
@@ -84,7 +77,7 @@ enum hlcache_retrieve_flag {
/**
* Initialise the high-level cache, preparing the llcache also.
*
- * \param hlcache_parameters Settings to initialise cache with
+ * \param hlcache_parameters Settings to initialise cache with
* \return NSERROR_OK on success, appropriate error otherwise.
*/
nserror hlcache_initialise(const struct hlcache_parameters *hlcache_parameters);
@@ -133,7 +126,7 @@ nserror hlcache_poll(void);
nserror hlcache_handle_retrieve(nsurl *url, uint32_t flags,
nsurl *referer, llcache_post_data *post,
hlcache_handle_callback cb, void *pw,
- hlcache_child_context *child,
+ hlcache_child_context *child,
content_type accepted_types, hlcache_handle **result);
/**
@@ -169,13 +162,13 @@ nserror hlcache_handle_replace_callback(hlcache_handle *handle,
* \param handle Cache handle to dereference
* \return Pointer to content object, or NULL if there is none
*
- * \todo This may not be correct. Ideally, the client should never need to
- * directly access a content object. It may, therefore, be better to provide a
- * bunch of veneers here that take a hlcache_handle and invoke the
+ * \todo This may not be correct. Ideally, the client should never need to
+ * directly access a content object. It may, therefore, be better to provide a
+ * bunch of veneers here that take a hlcache_handle and invoke the
* corresponding content_ API. If there's no content object associated with the
- * hlcache_handle (e.g. because the source data is still being fetched, so it
- * doesn't exist yet), then these veneers would behave as a NOP. The important
- * thing being that the client need not care about this possibility and can
+ * hlcache_handle (e.g. because the source data is still being fetched, so it
+ * doesn't exist yet), then these veneers would behave as a NOP. The important
+ * thing being that the client need not care about this possibility and can
* just call the functions with impugnity.
*/
struct content *hlcache_handle_get_content(const hlcache_handle *handle);
diff --git a/content/llcache.c b/content/llcache.c
index fa886be..2bcc37b 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -24,7 +24,6 @@
* store to extend their lifetime.
*
* \todo fix writeout conditions and ordering
- * \todo add backing store initialisation to set storage parameters like location and size limits.
* \todo implement expiry from backing store
* \todo make the reference backing store have an index to improve performance
* \todo make the reference backing store have a more efficient metadata store.
@@ -2749,20 +2748,21 @@ void llcache_clean(void)
/* See llcache.h for documentation */
nserror
-llcache_initialise(llcache_query_callback cb, void *pw, uint32_t llcache_limit)
+llcache_initialise(const struct llcache_parameters *prm)
{
llcache = calloc(1, sizeof(struct llcache_s));
if (llcache == NULL) {
return NSERROR_NOMEM;
}
- llcache->query_cb = cb;
- llcache->query_cb_pw = pw;
- llcache->limit = llcache_limit;
+ llcache->query_cb = prm->cb;
+ llcache->query_cb_pw = prm->cb_ctx;
+ llcache->limit = prm->limit;
- LOG(("llcache initialised with a limit of %d bytes", llcache_limit));
+ LOG(("llcache initialised with a limit of %d bytes", llcache->limit));
- return NSERROR_OK;
+ /* backing store initialisation */
+ return guit->llcache->initialise(&prm->store);
}
/* See llcache.h for documentation */
@@ -2812,6 +2812,9 @@ void llcache_finalise(void)
llcache_object_destroy(object);
}
+ /* backing store finalisation */
+ guit->llcache->finalise();
+
free(llcache);
llcache = NULL;
}
diff --git a/content/llcache.h b/content/llcache.h
index 3d8232c..6f12c48 100644
--- a/content/llcache.h
+++ b/content/llcache.h
@@ -76,7 +76,7 @@ typedef struct {
} data; /**< Event data */
} llcache_event;
-/**
+/**
* Client callback for low-level cache events
*
* \param handle Handle for which event is issued
@@ -84,18 +84,18 @@ typedef struct {
* \param pw Pointer to client-specific data
* \return NSERROR_OK on success, appropriate error otherwise.
*/
-typedef nserror (*llcache_handle_callback)(llcache_handle *handle,
+typedef nserror (*llcache_handle_callback)(llcache_handle *handle,
const llcache_event *event, void *pw);
/** Flags for low-level cache object retrieval */
enum llcache_retrieve_flag {
/* Note: We're permitted a maximum of 16 flags which must reside in the
- * bottom 16 bits of the flags word. See hlcache.h for further details.
+ * bottom 16 bits of the flags word. See hlcache.h for further details.
*/
/** Force a new fetch */
- LLCACHE_RETRIEVE_FORCE_FETCH = (1 << 0),
+ LLCACHE_RETRIEVE_FORCE_FETCH = (1 << 0),
/** Requested URL was verified */
- LLCACHE_RETRIEVE_VERIFIABLE = (1 << 1),
+ LLCACHE_RETRIEVE_VERIFIABLE = (1 << 1),
/**< No error pages */
LLCACHE_RETRIEVE_NO_ERROR_PAGES = (1 << 2),
/**< Stream data (implies that object is not cacheable) */
@@ -149,21 +149,44 @@ typedef nserror (*llcache_query_response)(bool proceed, void *cbpw);
* \param cbpw Opaque value to pass into \a cb
* \return NSERROR_OK on success, appropriate error otherwise
*
- * \note This callback should return immediately. Once a suitable answer to
- * the query has been obtained, the provided response callback should be
+ * \note This callback should return immediately. Once a suitable answer to
+ * the query has been obtained, the provided response callback should be
* called. This is intended to be an entirely asynchronous process.
*/
typedef nserror (*llcache_query_callback)(const llcache_query *query, void *pw,
llcache_query_response cb, void *cbpw);
/**
+ * Parameters to configure the low level cache backing store.
+ */
+struct llcache_store_parameters {
+ const char *path; /**< The path to the backing store */
+
+ size_t limit; /**< The backing store upper bound target size */
+ size_t hysteresis; /**< The hysteresis around the target size */
+};
+
+/**
+ * Parameters to configure the low level cache.
+ */
+struct llcache_parameters {
+ llcache_query_callback cb; /**< Query handler for llcache */
+ void *cb_ctx; /**< Pointer to llcache query handler data */
+
+ size_t limit; /**< The target upper bound for the RAM cache size */
+ size_t hysteresis; /**< The hysteresis around the target size */
+
+ struct llcache_store_parameters store;
+};
+
+/**
* Initialise the low-level cache
*
* \param cb Query handler
* \param pw Pointer to query handler data
* \return NSERROR_OK on success, appropriate error otherwise.
*/
-nserror llcache_initialise(llcache_query_callback cb, void *pw, uint32_t llcache_limit);
+nserror llcache_initialise(const struct llcache_parameters *parameters);
/**
* Finalise the low-level cache
@@ -280,12 +303,12 @@ const uint8_t *llcache_handle_get_source_data(const llcache_handle *handle,
* \return Header value, or NULL if header does not exist
*
* \todo Make the key an enumeration, to avoid needless string comparisons
- * \todo Forcing the client to parse the header value seems wrong.
- * Better would be to return the actual value part and an array of
+ * \todo Forcing the client to parse the header value seems wrong.
+ * Better would be to return the actual value part and an array of
* key-value pairs for any additional parameters.
* \todo Deal with multiple headers of the same key (e.g. Set-Cookie)
*/
-const char *llcache_handle_get_header(const llcache_handle *handle,
+const char *llcache_handle_get_header(const llcache_handle *handle,
const char *key);
/**
@@ -295,7 +318,7 @@ const char *llcache_handle_get_header(const llcache_handle *handle,
* \param b Second handle
* \return True if handles reference the same object, false otherwise
*/
-bool llcache_handle_references_same_object(const llcache_handle *a,
+bool llcache_handle_references_same_object(const llcache_handle *a,
const llcache_handle *b);
#endif
diff --git a/content/llcache_private.h b/content/llcache_private.h
index f038c9d..dc6cb86 100644
--- a/content/llcache_private.h
+++ b/content/llcache_private.h
@@ -25,13 +25,19 @@
#include "content/llcache.h"
-/** low level cache operation table
+/** low level cache backing store operation table
*
* The low level cache (source objects) has the capability to make
* objects and their metadata (headers etc) persistant by writing to a
* backing store using these operations.
*/
struct gui_llcache_table {
+ /** Initialise the backing store. */
+ nserror (*initialise)(const struct llcache_store_parameters *parameters);
+
+ /** Finalise the backing store. */
+ nserror (*finalise)(void);
+
/** Place a source object and its metadata in the backing store. */
nserror (*store)(struct nsurl *url,
const uint8_t *metadata, const size_t metadatalen,
diff --git a/desktop/gui_factory.c b/desktop/gui_factory.c
index 71fb226..3a33f51 100644
--- a/desktop/gui_factory.c
+++ b/desktop/gui_factory.c
@@ -346,6 +346,18 @@ static nserror verify_utf8_register(struct gui_utf8_table *gut)
}
static nserror
+gui_default_initialise(const struct llcache_store_parameters *parameters)
+{
+ return NSERROR_OK;
+}
+
+static nserror
+gui_default_finalise(void)
+{
+ return NSERROR_OK;
+}
+
+static nserror
gui_default_store(nsurl *url,
const uint8_t *metadata, const size_t metadatalen,
const uint8_t *data, const size_t datalen)
@@ -373,6 +385,8 @@ gui_default_invalidate(nsurl *url)
static struct gui_llcache_table default_llcache_table = {
+ .initialise = gui_default_initialise,
+ .finalise = gui_default_finalise,
.store = gui_default_store,
.fetch = gui_default_fetch,
.meta = gui_default_meta,
@@ -400,6 +414,15 @@ static nserror verify_llcache_register(struct gui_llcache_table *glt)
if (glt->invalidate == NULL) {
return NSERROR_BAD_PARAMETER;
}
+
+ /* fill in the optional entries with defaults */
+ if (glt->initialise == NULL) {
+ glt->initialise = gui_default_initialise;
+ }
+ if (glt->finalise == NULL) {
+ glt->finalise = gui_default_finalise;
+ }
+
return NSERROR_OK;
}
diff --git a/desktop/netsurf.c b/desktop/netsurf.c
index c3653b5..67ae868 100644
--- a/desktop/netsurf.c
+++ b/desktop/netsurf.c
@@ -116,12 +116,13 @@ static nserror netsurf_llcache_query_handler(const llcache_query *query,
nserror netsurf_init(const char *messages, struct gui_table *gt)
{
- nserror error;
+ nserror ret;
struct utsname utsname;
- nserror ret = NSERROR_OK;
struct hlcache_parameters hlcache_parameters = {
.bg_clean_time = HL_CACHE_CLEAN_TIME,
- .cb = netsurf_llcache_query_handler,
+ .llcache = {
+ .cb = netsurf_llcache_query_handler,
+ }
};
struct image_cache_parameters image_cache_parameters = {
.bg_clean_time = IMAGE_CACHE_CLEAN_TIME,
@@ -149,82 +150,94 @@ nserror netsurf_init(const char *messages, struct gui_table *gt)
utsname.version, utsname.machine));
/* register the gui handlers */
- error = gui_factory_register(gt);
- if (error != NSERROR_OK)
- return error;
+ ret = gui_factory_register(gt);
+ if (ret != NSERROR_OK)
+ return ret;
messages_load(messages);
/* corestrings init */
- error = corestrings_init();
- if (error != NSERROR_OK)
- return error;
+ ret = corestrings_init();
+ if (ret != NSERROR_OK)
+ return ret;
/* set up cache limits based on the memory cache size option */
- hlcache_parameters.limit = nsoption_int(memory_cache_size);
+ hlcache_parameters.llcache.limit = nsoption_int(memory_cache_size);
- if (hlcache_parameters.limit < MINIMUM_MEMORY_CACHE_SIZE) {
- hlcache_parameters.limit = MINIMUM_MEMORY_CACHE_SIZE;
- LOG(("Setting minimum memory cache size to %d",
- hlcache_parameters.limit));
+ if (hlcache_parameters.llcache.limit < MINIMUM_MEMORY_CACHE_SIZE) {
+ hlcache_parameters.llcache.limit = MINIMUM_MEMORY_CACHE_SIZE;
+ LOG(("Setting minimum memory cache size %d",
+ hlcache_parameters.llcache.limit));
}
/* image cache is 25% of total memory cache size */
- image_cache_parameters.limit = (hlcache_parameters.limit * 25) / 100;
+ image_cache_parameters.limit = (hlcache_parameters.llcache.limit * 25) / 100;
/* image cache hysteresis is 20% of the image cache size */
image_cache_parameters.hysteresis = (image_cache_parameters.limit * 20) / 100;
/* account for image cache use from total */
- hlcache_parameters.limit -= image_cache_parameters.limit;
+ hlcache_parameters.llcache.limit -= image_cache_parameters.limit;
+
+ /* set backing store target limit */
+ hlcache_parameters.llcache.store.limit = nsoption_int(disc_cache_size);
+
+ /* set backing store hysterissi to 20% */
+ hlcache_parameters.llcache.store.hysteresis = (hlcache_parameters.llcache.store.limit * 20) / 100;;
+
+ /* set the path to the backing store */
+ /** \todo set the backing store path properly */
+ hlcache_parameters.llcache.store.path = "/tmp/ns/";
/* image handler bitmap cache */
- error = image_cache_init(&image_cache_parameters);
- if (error != NSERROR_OK)
- return error;
+ ret = image_cache_init(&image_cache_parameters);
+ if (ret != NSERROR_OK)
+ return ret;
/* content handler initialisation */
- error = nscss_init();
- if (error != NSERROR_OK)
- return error;
+ ret = nscss_init();
+ if (ret != NSERROR_OK)
+ return ret;
- error = html_init();
- if (error != NSERROR_OK)
- return error;
+ ret = html_init();
+ if (ret != NSERROR_OK)
+ return ret;
- error = image_init();
- if (error != NSERROR_OK)
- return error;
+ ret = image_init();
+ if (ret != NSERROR_OK)
+ return ret;
- error = textplain_init();
- if (error != NSERROR_OK)
- return error;
+ ret = textplain_init();
+ if (ret != NSERROR_OK)
+ return ret;
- error = mimesniff_init();
- if (error != NSERROR_OK)
- return error;
+ ret = mimesniff_init();
+ if (ret != NSERROR_OK)
+ return ret;
url_init();
setlocale(LC_ALL, "C");
/* initialise the fetchers */
- error = fetch_init();
- if (error != NSERROR_OK)
- return error;
+ ret = fetch_init();
+ if (ret != NSERROR_OK)
+ return ret;
/* Initialise the hlcache and allow it to init the llcache for us */
- hlcache_initialise(&hlcache_parameters);
+ ret = hlcache_initialise(&hlcache_parameters);
+ if (ret != NSERROR_OK)
+ return ret;
/* Initialize system colours */
- error = ns_system_colour_init();
- if (error != NSERROR_OK)
- return error;
+ ret = ns_system_colour_init();
+ if (ret != NSERROR_OK)
+ return ret;
js_initialise();
- return ret;
+ return NSERROR_OK;
}
--
NetSurf Browser
8 years, 11 months
netsurf: branch master updated. release/3.0-1131-g69b6119
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/69b61198f28a510eba34e...
...commit http://git.netsurf-browser.org/netsurf.git/commit/69b61198f28a510eba34eca...
...tree http://git.netsurf-browser.org/netsurf.git/tree/69b61198f28a510eba34eca74...
The branch, master has been updated
via 69b61198f28a510eba34eca747e8d5eacfee4a0a (commit)
via 6bcd221d0d3946abfddf40a7c73a8d9619b0ff78 (commit)
via a2d4c8ee0fd9a8036dcdbdd642a36aa92ddba409 (commit)
from 32a522241f94970df9681517edc999d7b6d6675a (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=69b61198f28a510eba3...
commit 69b61198f28a510eba34eca747e8d5eacfee4a0a
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Return 1 if help closed.
diff --git a/amiga/agclass/amigaguide_class.c b/amiga/agclass/amigaguide_class.c
index 8150717..9d69e96 100644
--- a/amiga/agclass/amigaguide_class.c
+++ b/amiga/agclass/amigaguide_class.c
@@ -368,6 +368,7 @@ uint32 agm_process(Class *cl, Object *o, Msg msg)
{
case ShutdownMsgID:
agm_close(cl, o, msg);
+ retVal = 1L;
break;
default:
diff --git a/amiga/help.c b/amiga/help.c
index a2e4f05..8914440 100755
--- a/amiga/help.c
+++ b/amiga/help.c
@@ -78,6 +78,6 @@ ULONG ami_help_signal(void)
void ami_help_process(void)
{
ULONG ret = IDoMethod(AmigaGuideObject, AGM_PROCESS, NULL);
- if(ret == NULL) ami_help_free();
+ if(ret) ami_help_free();
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=6bcd221d0d3946abfdd...
commit 6bcd221d0d3946abfddf40a7c73a8d9619b0ff78
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Re-apply some of my previous changes
diff --git a/amiga/agclass/amigaguide_class.c b/amiga/agclass/amigaguide_class.c
index 6f504a7..8150717 100644
--- a/amiga/agclass/amigaguide_class.c
+++ b/amiga/agclass/amigaguide_class.c
@@ -4,6 +4,7 @@
* by Daniel "Trixie" Jedlicka
*/
+#undef __USE_INLINE__
#include "amigaguide_class.h"
@@ -261,6 +262,11 @@ uint32 om_get(Class *cl, Object *o, struct opGet *msg)
retVal = 1L;
break;
+ case AMIGAGUIDE_Signal:
+ *(msg->opg_Storage) = (uint32)lod->agSignal;
+ retVal = 1L;
+ break;
+
default:
retVal = IIntuition->IDoSuperMethodA(cl, o, (Msg)msg);
}
@@ -335,6 +341,7 @@ uint32 agm_close(Class *cl, Object *o, Msg msg)
{
IAmigaGuide->CloseAmigaGuide(lod->agHandle);
lod->agHandle = NULL;
+ lod->agSignal = 0;
retVal = 1L;
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=a2d4c8ee0fd9a8036dc...
commit a2d4c8ee0fd9a8036dcdbdd642a36aa92ddba409
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Updated amigaguide.class from Daniel Jedlicka
diff --git a/amiga/agclass/amigaguide_class.c b/amiga/agclass/amigaguide_class.c
old mode 100755
new mode 100644
index 9d7b8bb..6f504a7
--- a/amiga/agclass/amigaguide_class.c
+++ b/amiga/agclass/amigaguide_class.c
@@ -4,10 +4,11 @@
* by Daniel "Trixie" Jedlicka
*/
-#undef __USE_INLINE__
#include "amigaguide_class.h"
+
+
struct localObjectData
{
struct NewAmigaGuide nag;
@@ -15,7 +16,6 @@ struct localObjectData
AMIGAGUIDECONTEXT agHandle;
uint32 agContextID;
uint32 agSignal;
- BOOL agActive;
};
struct Library *AmigaGuideBase = NULL;
@@ -36,6 +36,7 @@ uint32 agm_open(Class *, Object *, Msg);
uint32 agm_close(Class *, Object *, Msg);
uint32 agm_process(Class *, Object *, Msg);
+
/* *************************** class initialization and disposal ***************************** */
@@ -131,7 +132,6 @@ uint32 om_new(Class *cl, Object *o, struct opSet *msg)
if ( (lod = (struct localObjectData *)INST_DATA(cl, retVal)) )
{
// Initialize values.
- lod->agActive = FALSE;
lod->agHandle = NULL;
lod->agContextID = 0;
lod->nag.nag_Name = NULL;
@@ -172,10 +172,9 @@ uint32 om_dispose(Class *cl, Object *o, Msg msg)
uint32 om_set(Class *cl, Object *o, struct opSet *msg)
{
struct localObjectData *lod = (struct localObjectData *)INST_DATA(cl, o);
- struct TagItem *tags, *ti;
-
-
- tags = msg->ops_AttrList;
+ struct TagItem *ti = NULL, *tags = msg->ops_AttrList;
+ uint32 retVal = 0L;
+
while ((ti = IUtility->NextTagItem (&tags)))
{
@@ -183,31 +182,32 @@ uint32 om_set(Class *cl, Object *o, struct opSet *msg)
{
case AMIGAGUIDE_Name:
lod->nag.nag_Name = (STRPTR)ti->ti_Data;
- lod->agActive = FALSE; // Database name has changed, we must setup the help system again.
+ retVal++;
break;
case AMIGAGUIDE_Screen:
lod->nag.nag_Screen = (struct Screen *)ti->ti_Data;
- lod->agActive = FALSE; // Screen pointer has changed, we must setup the help system again.
+ retVal++;
break;
case AMIGAGUIDE_PubScreen:
lod->nag.nag_PubScreen = (STRPTR)ti->ti_Data;
- lod->agActive = FALSE; // Pubscreen name has changed, we must setup the help system again.
+ retVal++;
break;
case AMIGAGUIDE_BaseName:
lod->nag.nag_BaseName = (STRPTR)ti->ti_Data;
- lod->agActive = FALSE; // Application basename has changed, we must setup the help system again.
+ retVal++;
break;
case AMIGAGUIDE_ContextArray:
lod->nag.nag_Context = (STRPTR *)ti->ti_Data;
- lod->agActive = FALSE; // Context array has changed, we must setup the help system again.
+ retVal++;
break;
case AMIGAGUIDE_ContextID:
lod->agContextID = (uint32)ti->ti_Data;
+ retVal++;
break;
default:
@@ -215,38 +215,7 @@ uint32 om_set(Class *cl, Object *o, struct opSet *msg)
}
}
-
- // Setup the help system, if not ready yet or needs changing.
- if ( lod->agActive == FALSE )
- {
- // Shut down help system should it already be running.
- if ( lod->agHandle ) agm_close(cl, o, (Msg)msg);
-
- // (Re)establish the AmigaGuide context and open the database asynchronously.
- if ( (lod->agHandle = IAmigaGuide->OpenAmigaGuideAsync(&(lod->nag), NULL)) )
- {
- if ( (lod->agSignal = IAmigaGuide->AmigaGuideSignal(lod->agHandle)) )
- {
- // Wait until the help system is up and running.
- IExec->Wait(lod->agSignal);
- while ( !(lod->agActive) )
- {
- while ( (lod->agm = IAmigaGuide->GetAmigaGuideMsg(lod->agHandle)) )
- {
- // The AmigaGuide process started OK.
- if ( lod->agm->agm_Type == ActiveToolID ) lod->agActive = TRUE;
-
- // Opening the guide file failed for some reason, continue as usual.
- if ( lod->agm->agm_Type == ToolStatusID && lod->agm->agm_Pri_Ret ) lod->agActive = TRUE;
-
- IAmigaGuide->ReplyAmigaGuideMsg(lod->agm);
- }
- }
- }
- }
- }
-
- return (uint32)lod->agHandle;
+ return retVal;
}
@@ -264,37 +233,32 @@ uint32 om_get(Class *cl, Object *o, struct opGet *msg)
{
case AMIGAGUIDE_Name:
*(msg->opg_Storage) = (uint32)lod->nag.nag_Name;
- retVal = 1;
+ retVal = 1L;
break;
case AMIGAGUIDE_Screen:
*(msg->opg_Storage) = (uint32)lod->nag.nag_Screen;
- retVal = 1;
+ retVal = 1L;
break;
case AMIGAGUIDE_PubScreen:
*(msg->opg_Storage) = (uint32)lod->nag.nag_PubScreen;
- retVal = 1;
+ retVal = 1L;
break;
case AMIGAGUIDE_BaseName:
*(msg->opg_Storage) = (uint32)lod->nag.nag_BaseName;
- retVal = 1;
+ retVal = 1L;
break;
case AMIGAGUIDE_ContextArray:
*(msg->opg_Storage) = (uint32)lod->nag.nag_Context;
- retVal = 1;
+ retVal = 1L;
break;
case AMIGAGUIDE_ContextID:
*(msg->opg_Storage) = (uint32)lod->agContextID;
- retVal = 1;
- break;
-
- case AMIGAGUIDE_Signal:
- *(msg->opg_Storage) = (uint32)lod->agSignal;
- retVal = 1;
+ retVal = 1L;
break;
default:
@@ -312,23 +276,47 @@ uint32 om_get(Class *cl, Object *o, struct opGet *msg)
uint32 agm_open(Class *cl, Object *o, Msg msg)
{
struct localObjectData *lod = (struct localObjectData *)INST_DATA(cl, o);
- uint32 retVal = 0;
+ BOOL agActive = FALSE;
+ uint32 retVal = 0L;
- if ( (lod->agHandle) && (lod->agActive) )
- {
- if ( lod->nag.nag_Context )
- {
- // A context node array is provided = open the current context node.
- IAmigaGuide->SetAmigaGuideContext(lod->agHandle, lod->agContextID, NULL);
- retVal = IAmigaGuide->SendAmigaGuideContext(lod->agHandle, NULL);
- }
- else
+ // Close a previous instance.
+ if ( lod->agHandle ) agm_close(cl, o, msg);
+
+ // (Re)establish the AmigaGuide context and open the database asynchronously.
+ if ( (lod->agHandle = IAmigaGuide->OpenAmigaGuideAsync(&(lod->nag), NULL)) )
{
- // No context array is provided = open the main node.
- retVal = IAmigaGuide->SendAmigaGuideCmd(lod->agHandle, "LINK MAIN", TAG_DONE);
+ if ( (lod->agSignal = IAmigaGuide->AmigaGuideSignal(lod->agHandle)) )
+ {
+ // Wait until the database is displayed and ready.
+ IExec->Wait(lod->agSignal);
+ while ( agActive == FALSE )
+ {
+ while ( (lod->agm = IAmigaGuide->GetAmigaGuideMsg(lod->agHandle)) )
+ {
+ // The AmigaGuide process started OK.
+ if ( lod->agm->agm_Type == ActiveToolID ) agActive = TRUE;
+
+ // Opening the guide file failed for some reason, continue as usual.
+ if ( lod->agm->agm_Type == ToolStatusID && lod->agm->agm_Pri_Ret ) agActive = TRUE;
+
+ IAmigaGuide->ReplyAmigaGuideMsg(lod->agm);
+ }
+ }
+ if ( lod->nag.nag_Context )
+ {
+ // A context node array is provided = open the current context node.
+ IAmigaGuide->SetAmigaGuideContext(lod->agHandle, lod->agContextID, NULL);
+ retVal = IAmigaGuide->SendAmigaGuideContext(lod->agHandle, NULL);
+ }
+ else
+ {
+ // No context array is provided = open the main node.
+ retVal = IAmigaGuide->SendAmigaGuideCmd(lod->agHandle, "LINK MAIN", TAG_DONE);
+ }
+ }
}
- }
+
return retVal;
}
@@ -340,40 +328,50 @@ uint32 agm_open(Class *cl, Object *o, Msg msg)
uint32 agm_close(Class *cl, Object *o, Msg msg)
{
struct localObjectData *lod = (struct localObjectData *)INST_DATA(cl, o);
+ uint32 retVal = 0L;
if ( lod->agHandle )
{
IAmigaGuide->CloseAmigaGuide(lod->agHandle);
lod->agHandle = NULL;
- lod->agActive = FALSE;
- lod->agSignal = NULL;
+ retVal = 1L;
}
- return (uint32)lod->agHandle;
+ return retVal;
}
+
+
+
+
uint32 agm_process(Class *cl, Object *o, Msg msg)
{
- struct localObjectData *lod = (struct localObjectData *)INST_DATA(cl, o);
-
- if (lod->agHandle) {
- while ( (lod->agm = IAmigaGuide->GetAmigaGuideMsg(lod->agHandle)) ) {
- switch(lod->agm->agm_Type) {
- case ShutdownMsgID:
- agm_close(cl, o, (Msg)msg);
- break;
-
- default:
- //printf("%d\n", lod->agm->agm_Type);
- break;
- }
- }
- IAmigaGuide->ReplyAmigaGuideMsg(lod->agm);
- }
-
- return (uint32)lod->agHandle;
+ struct localObjectData *lod = (struct localObjectData *)INST_DATA(cl, o);
+ uint32 retVal = 0L;
+
+
+ if (lod->agHandle)
+ {
+ while ( (lod->agm = IAmigaGuide->GetAmigaGuideMsg(lod->agHandle)) )
+ {
+ switch (lod->agm->agm_Type)
+ {
+ case ShutdownMsgID:
+ agm_close(cl, o, msg);
+ break;
+
+ default:
+ //printf("%d\n", lod->agm->agm_Type);
+ break;
+ }
+ IAmigaGuide->ReplyAmigaGuideMsg(lod->agm);
+ }
+ }
+
+ return retVal;
+
}
-----------------------------------------------------------------------
Summary of changes:
amiga/agclass/amigaguide_class.c | 174 ++++++++++++++++++++------------------
amiga/help.c | 2 +-
2 files changed, 91 insertions(+), 85 deletions(-)
mode change 100755 => 100644 amiga/agclass/amigaguide_class.c
diff --git a/amiga/agclass/amigaguide_class.c b/amiga/agclass/amigaguide_class.c
old mode 100755
new mode 100644
index 9d7b8bb..9d69e96
--- a/amiga/agclass/amigaguide_class.c
+++ b/amiga/agclass/amigaguide_class.c
@@ -8,6 +8,8 @@
#include "amigaguide_class.h"
+
+
struct localObjectData
{
struct NewAmigaGuide nag;
@@ -15,7 +17,6 @@ struct localObjectData
AMIGAGUIDECONTEXT agHandle;
uint32 agContextID;
uint32 agSignal;
- BOOL agActive;
};
struct Library *AmigaGuideBase = NULL;
@@ -36,6 +37,7 @@ uint32 agm_open(Class *, Object *, Msg);
uint32 agm_close(Class *, Object *, Msg);
uint32 agm_process(Class *, Object *, Msg);
+
/* *************************** class initialization and disposal ***************************** */
@@ -131,7 +133,6 @@ uint32 om_new(Class *cl, Object *o, struct opSet *msg)
if ( (lod = (struct localObjectData *)INST_DATA(cl, retVal)) )
{
// Initialize values.
- lod->agActive = FALSE;
lod->agHandle = NULL;
lod->agContextID = 0;
lod->nag.nag_Name = NULL;
@@ -172,10 +173,9 @@ uint32 om_dispose(Class *cl, Object *o, Msg msg)
uint32 om_set(Class *cl, Object *o, struct opSet *msg)
{
struct localObjectData *lod = (struct localObjectData *)INST_DATA(cl, o);
- struct TagItem *tags, *ti;
-
-
- tags = msg->ops_AttrList;
+ struct TagItem *ti = NULL, *tags = msg->ops_AttrList;
+ uint32 retVal = 0L;
+
while ((ti = IUtility->NextTagItem (&tags)))
{
@@ -183,31 +183,32 @@ uint32 om_set(Class *cl, Object *o, struct opSet *msg)
{
case AMIGAGUIDE_Name:
lod->nag.nag_Name = (STRPTR)ti->ti_Data;
- lod->agActive = FALSE; // Database name has changed, we must setup the help system again.
+ retVal++;
break;
case AMIGAGUIDE_Screen:
lod->nag.nag_Screen = (struct Screen *)ti->ti_Data;
- lod->agActive = FALSE; // Screen pointer has changed, we must setup the help system again.
+ retVal++;
break;
case AMIGAGUIDE_PubScreen:
lod->nag.nag_PubScreen = (STRPTR)ti->ti_Data;
- lod->agActive = FALSE; // Pubscreen name has changed, we must setup the help system again.
+ retVal++;
break;
case AMIGAGUIDE_BaseName:
lod->nag.nag_BaseName = (STRPTR)ti->ti_Data;
- lod->agActive = FALSE; // Application basename has changed, we must setup the help system again.
+ retVal++;
break;
case AMIGAGUIDE_ContextArray:
lod->nag.nag_Context = (STRPTR *)ti->ti_Data;
- lod->agActive = FALSE; // Context array has changed, we must setup the help system again.
+ retVal++;
break;
case AMIGAGUIDE_ContextID:
lod->agContextID = (uint32)ti->ti_Data;
+ retVal++;
break;
default:
@@ -215,38 +216,7 @@ uint32 om_set(Class *cl, Object *o, struct opSet *msg)
}
}
-
- // Setup the help system, if not ready yet or needs changing.
- if ( lod->agActive == FALSE )
- {
- // Shut down help system should it already be running.
- if ( lod->agHandle ) agm_close(cl, o, (Msg)msg);
-
- // (Re)establish the AmigaGuide context and open the database asynchronously.
- if ( (lod->agHandle = IAmigaGuide->OpenAmigaGuideAsync(&(lod->nag), NULL)) )
- {
- if ( (lod->agSignal = IAmigaGuide->AmigaGuideSignal(lod->agHandle)) )
- {
- // Wait until the help system is up and running.
- IExec->Wait(lod->agSignal);
- while ( !(lod->agActive) )
- {
- while ( (lod->agm = IAmigaGuide->GetAmigaGuideMsg(lod->agHandle)) )
- {
- // The AmigaGuide process started OK.
- if ( lod->agm->agm_Type == ActiveToolID ) lod->agActive = TRUE;
-
- // Opening the guide file failed for some reason, continue as usual.
- if ( lod->agm->agm_Type == ToolStatusID && lod->agm->agm_Pri_Ret ) lod->agActive = TRUE;
-
- IAmigaGuide->ReplyAmigaGuideMsg(lod->agm);
- }
- }
- }
- }
- }
-
- return (uint32)lod->agHandle;
+ return retVal;
}
@@ -264,37 +234,37 @@ uint32 om_get(Class *cl, Object *o, struct opGet *msg)
{
case AMIGAGUIDE_Name:
*(msg->opg_Storage) = (uint32)lod->nag.nag_Name;
- retVal = 1;
+ retVal = 1L;
break;
case AMIGAGUIDE_Screen:
*(msg->opg_Storage) = (uint32)lod->nag.nag_Screen;
- retVal = 1;
+ retVal = 1L;
break;
case AMIGAGUIDE_PubScreen:
*(msg->opg_Storage) = (uint32)lod->nag.nag_PubScreen;
- retVal = 1;
+ retVal = 1L;
break;
case AMIGAGUIDE_BaseName:
*(msg->opg_Storage) = (uint32)lod->nag.nag_BaseName;
- retVal = 1;
+ retVal = 1L;
break;
case AMIGAGUIDE_ContextArray:
*(msg->opg_Storage) = (uint32)lod->nag.nag_Context;
- retVal = 1;
+ retVal = 1L;
break;
case AMIGAGUIDE_ContextID:
*(msg->opg_Storage) = (uint32)lod->agContextID;
- retVal = 1;
+ retVal = 1L;
break;
case AMIGAGUIDE_Signal:
*(msg->opg_Storage) = (uint32)lod->agSignal;
- retVal = 1;
+ retVal = 1L;
break;
default:
@@ -312,23 +282,47 @@ uint32 om_get(Class *cl, Object *o, struct opGet *msg)
uint32 agm_open(Class *cl, Object *o, Msg msg)
{
struct localObjectData *lod = (struct localObjectData *)INST_DATA(cl, o);
- uint32 retVal = 0;
+ BOOL agActive = FALSE;
+ uint32 retVal = 0L;
- if ( (lod->agHandle) && (lod->agActive) )
- {
- if ( lod->nag.nag_Context )
- {
- // A context node array is provided = open the current context node.
- IAmigaGuide->SetAmigaGuideContext(lod->agHandle, lod->agContextID, NULL);
- retVal = IAmigaGuide->SendAmigaGuideContext(lod->agHandle, NULL);
- }
- else
+ // Close a previous instance.
+ if ( lod->agHandle ) agm_close(cl, o, msg);
+
+ // (Re)establish the AmigaGuide context and open the database asynchronously.
+ if ( (lod->agHandle = IAmigaGuide->OpenAmigaGuideAsync(&(lod->nag), NULL)) )
{
- // No context array is provided = open the main node.
- retVal = IAmigaGuide->SendAmigaGuideCmd(lod->agHandle, "LINK MAIN", TAG_DONE);
+ if ( (lod->agSignal = IAmigaGuide->AmigaGuideSignal(lod->agHandle)) )
+ {
+ // Wait until the database is displayed and ready.
+ IExec->Wait(lod->agSignal);
+ while ( agActive == FALSE )
+ {
+ while ( (lod->agm = IAmigaGuide->GetAmigaGuideMsg(lod->agHandle)) )
+ {
+ // The AmigaGuide process started OK.
+ if ( lod->agm->agm_Type == ActiveToolID ) agActive = TRUE;
+
+ // Opening the guide file failed for some reason, continue as usual.
+ if ( lod->agm->agm_Type == ToolStatusID && lod->agm->agm_Pri_Ret ) agActive = TRUE;
+
+ IAmigaGuide->ReplyAmigaGuideMsg(lod->agm);
+ }
+ }
+ if ( lod->nag.nag_Context )
+ {
+ // A context node array is provided = open the current context node.
+ IAmigaGuide->SetAmigaGuideContext(lod->agHandle, lod->agContextID, NULL);
+ retVal = IAmigaGuide->SendAmigaGuideContext(lod->agHandle, NULL);
+ }
+ else
+ {
+ // No context array is provided = open the main node.
+ retVal = IAmigaGuide->SendAmigaGuideCmd(lod->agHandle, "LINK MAIN", TAG_DONE);
+ }
+ }
}
- }
+
return retVal;
}
@@ -340,40 +334,52 @@ uint32 agm_open(Class *cl, Object *o, Msg msg)
uint32 agm_close(Class *cl, Object *o, Msg msg)
{
struct localObjectData *lod = (struct localObjectData *)INST_DATA(cl, o);
+ uint32 retVal = 0L;
if ( lod->agHandle )
{
IAmigaGuide->CloseAmigaGuide(lod->agHandle);
lod->agHandle = NULL;
- lod->agActive = FALSE;
- lod->agSignal = NULL;
+ lod->agSignal = 0;
+ retVal = 1L;
}
- return (uint32)lod->agHandle;
+ return retVal;
}
+
+
+
+
uint32 agm_process(Class *cl, Object *o, Msg msg)
{
- struct localObjectData *lod = (struct localObjectData *)INST_DATA(cl, o);
-
- if (lod->agHandle) {
- while ( (lod->agm = IAmigaGuide->GetAmigaGuideMsg(lod->agHandle)) ) {
- switch(lod->agm->agm_Type) {
- case ShutdownMsgID:
- agm_close(cl, o, (Msg)msg);
- break;
-
- default:
- //printf("%d\n", lod->agm->agm_Type);
- break;
- }
- }
- IAmigaGuide->ReplyAmigaGuideMsg(lod->agm);
- }
-
- return (uint32)lod->agHandle;
+ struct localObjectData *lod = (struct localObjectData *)INST_DATA(cl, o);
+ uint32 retVal = 0L;
+
+
+ if (lod->agHandle)
+ {
+ while ( (lod->agm = IAmigaGuide->GetAmigaGuideMsg(lod->agHandle)) )
+ {
+ switch (lod->agm->agm_Type)
+ {
+ case ShutdownMsgID:
+ agm_close(cl, o, msg);
+ retVal = 1L;
+ break;
+
+ default:
+ //printf("%d\n", lod->agm->agm_Type);
+ break;
+ }
+ IAmigaGuide->ReplyAmigaGuideMsg(lod->agm);
+ }
+ }
+
+ return retVal;
+
}
diff --git a/amiga/help.c b/amiga/help.c
index a2e4f05..8914440 100755
--- a/amiga/help.c
+++ b/amiga/help.c
@@ -78,6 +78,6 @@ ULONG ami_help_signal(void)
void ami_help_process(void)
{
ULONG ret = IDoMethod(AmigaGuideObject, AGM_PROCESS, NULL);
- if(ret == NULL) ami_help_free();
+ if(ret) ami_help_free();
}
--
NetSurf Browser
8 years, 11 months
netsurf: branch master updated. release/3.0-1128-g32a5222
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/32a522241f94970df9681...
...commit http://git.netsurf-browser.org/netsurf.git/commit/32a522241f94970df968151...
...tree http://git.netsurf-browser.org/netsurf.git/tree/32a522241f94970df9681517e...
The branch, master has been updated
via 32a522241f94970df9681517edc999d7b6d6675a (commit)
from 71cb70065e6819c26f101ff11e34c10383487b30 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=32a522241f94970df96...
commit 32a522241f94970df9681517edc999d7b6d6675a
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Rename function arguments to avoid using 'new'.
diff --git a/desktop/browser_history.c b/desktop/browser_history.c
index ca551f7..8c21eed 100644
--- a/desktop/browser_history.c
+++ b/desktop/browser_history.c
@@ -443,36 +443,39 @@ nserror browser_window_history_create(struct browser_window *bw)
/**
* Clone a bw's history tree for new bw
*
- * \param bw browser window with history to clone.
- * \param new browser window to make cloned history for.
+ * \param existing browser window with history to clone.
+ * \param clone browser window to make cloned history for.
*
* \return NSERROR_OK or appropriate error otherwise
*/
-nserror browser_window_history_clone(const struct browser_window *bw,
- struct browser_window *new)
+nserror browser_window_history_clone(const struct browser_window *existing,
+ struct browser_window *clone)
{
struct history *new_history;
- new->history = NULL;
+ clone->history = NULL;
- if (bw == NULL || bw->history == NULL || bw->history->start == NULL)
- return browser_window_history_create(new);
+ if (existing == NULL || existing->history == NULL ||
+ existing->history->start == NULL)
+ /* Nothing to clone, create new history for clone window */
+ return browser_window_history_create(clone);
+ /* Make cloned history */
new_history = malloc(sizeof *new_history);
if (!new_history)
return NSERROR_NOMEM;
- new->history = new_history;
- memcpy(new_history, bw->history, sizeof *new_history);
+ clone->history = new_history;
+ memcpy(new_history, existing->history, sizeof *new_history);
new_history->start = browser_window_history__clone_entry(new_history,
new_history->start);
if (!new_history->start) {
LOG(("Insufficient memory to clone history"));
warn_user("NoMemory", 0);
- browser_window_history_destroy(new);
- new->history = NULL;
+ browser_window_history_destroy(clone);
+ clone->history = NULL;
return NSERROR_NOMEM;
}
diff --git a/desktop/browser_history.h b/desktop/browser_history.h
index 11b58e4..f3e524b 100644
--- a/desktop/browser_history.h
+++ b/desktop/browser_history.h
@@ -34,8 +34,8 @@ struct history_entry;
struct redraw_context;
nserror browser_window_history_create(struct browser_window *bw);
-nserror browser_window_history_clone(const struct browser_window *bw,
- struct browser_window *new);
+nserror browser_window_history_clone(const struct browser_window *existing,
+ struct browser_window *clone);
void browser_window_history_add(struct browser_window *bw,
struct hlcache_handle *content, lwc_string *frag_id);
void browser_window_history_update(struct browser_window *bw,
-----------------------------------------------------------------------
Summary of changes:
desktop/browser_history.c | 25 ++++++++++++++-----------
desktop/browser_history.h | 4 ++--
2 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/desktop/browser_history.c b/desktop/browser_history.c
index ca551f7..8c21eed 100644
--- a/desktop/browser_history.c
+++ b/desktop/browser_history.c
@@ -443,36 +443,39 @@ nserror browser_window_history_create(struct browser_window *bw)
/**
* Clone a bw's history tree for new bw
*
- * \param bw browser window with history to clone.
- * \param new browser window to make cloned history for.
+ * \param existing browser window with history to clone.
+ * \param clone browser window to make cloned history for.
*
* \return NSERROR_OK or appropriate error otherwise
*/
-nserror browser_window_history_clone(const struct browser_window *bw,
- struct browser_window *new)
+nserror browser_window_history_clone(const struct browser_window *existing,
+ struct browser_window *clone)
{
struct history *new_history;
- new->history = NULL;
+ clone->history = NULL;
- if (bw == NULL || bw->history == NULL || bw->history->start == NULL)
- return browser_window_history_create(new);
+ if (existing == NULL || existing->history == NULL ||
+ existing->history->start == NULL)
+ /* Nothing to clone, create new history for clone window */
+ return browser_window_history_create(clone);
+ /* Make cloned history */
new_history = malloc(sizeof *new_history);
if (!new_history)
return NSERROR_NOMEM;
- new->history = new_history;
- memcpy(new_history, bw->history, sizeof *new_history);
+ clone->history = new_history;
+ memcpy(new_history, existing->history, sizeof *new_history);
new_history->start = browser_window_history__clone_entry(new_history,
new_history->start);
if (!new_history->start) {
LOG(("Insufficient memory to clone history"));
warn_user("NoMemory", 0);
- browser_window_history_destroy(new);
- new->history = NULL;
+ browser_window_history_destroy(clone);
+ clone->history = NULL;
return NSERROR_NOMEM;
}
diff --git a/desktop/browser_history.h b/desktop/browser_history.h
index 11b58e4..f3e524b 100644
--- a/desktop/browser_history.h
+++ b/desktop/browser_history.h
@@ -34,8 +34,8 @@ struct history_entry;
struct redraw_context;
nserror browser_window_history_create(struct browser_window *bw);
-nserror browser_window_history_clone(const struct browser_window *bw,
- struct browser_window *new);
+nserror browser_window_history_clone(const struct browser_window *existing,
+ struct browser_window *clone);
void browser_window_history_add(struct browser_window *bw,
struct hlcache_handle *content, lwc_string *frag_id);
void browser_window_history_update(struct browser_window *bw,
--
NetSurf Browser
8 years, 11 months
netsurf: branch vince/disccache updated. release/3.0-1132-gab1a76e
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/ab1a76ee8ab178cc52050...
...commit http://git.netsurf-browser.org/netsurf.git/commit/ab1a76ee8ab178cc52050c1...
...tree http://git.netsurf-browser.org/netsurf.git/tree/ab1a76ee8ab178cc52050c1e2...
The branch, vince/disccache has been updated
via ab1a76ee8ab178cc52050c1e29a28775a0a6636d (commit)
from 49fb39fc4535aaba2a50f911a73183b46a2f3812 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=ab1a76ee8ab178cc520...
commit ab1a76ee8ab178cc52050c1e29a28775a0a6636d
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
make metadata format easier to parse by using null termination
diff --git a/content/llcache.c b/content/llcache.c
index 1b354b5..fa886be 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -27,12 +27,12 @@
* \todo add backing store initialisation to set storage parameters like location and size limits.
* \todo implement expiry from backing store
* \todo make the reference backing store have an index to improve performance
- * \todo make the reference backing store have a more efficient metadata store.
+ * \todo make the reference backing store have a more efficient metadata store.
* \todo make the reference backing store cope with filesystems that have filename length limits and directory entry count limits
* \todo make backing store size bounded by configuration
* \todo support mmaped retrieve
- * \todo store metadata in a more easily handled format (null termineted)
* \todo make metadata buffer owned by backing store (avoid allocation and freeing)
+ * \todo instrument and (auto)tune
* \todo turn llcache debugging off
*/
@@ -1037,8 +1037,8 @@ static nserror llcache_object_clone_cache_data(llcache_object *source,
* \param list List to remove from
* \return NSERROR_OK
*/
-static nserror llcache_object_remove_from_list(llcache_object *object,
- llcache_object **list)
+static nserror
+llcache_object_remove_from_list(llcache_object *object, llcache_object **list)
{
if (object == *list)
*list = object->next;
@@ -1061,8 +1061,7 @@ static nserror llcache_object_remove_from_list(llcache_object *object,
* @param object the object to operate on.
* @return apropriate error code.
*/
-static nserror
-llcache_persist_retrieve(llcache_object *object)
+static nserror llcache_persist_retrieve(llcache_object *object)
{
/* ensure the source data is present if necessary */
if ((object->source_data != NULL) ||
@@ -1079,26 +1078,6 @@ llcache_persist_retrieve(llcache_object *object)
&object->source_len);
}
-/**
- * find and null terminate a crlf terminated line.
- *
- * @param data the beginning of the data to search.
- * @param end the end of the data.
- * @return pointer to the next line or NULL if the end of input was reached.
- */
-static uint8_t *crlf_line(uint8_t *data, uint8_t *end)
-{
- uint8_t *nln = data;
- while ((nln < end) && ((nln[0] != 13) || (nln[1] != 10) ))
- nln++;
-
- if (nln == end)
- return NULL;
-
- nln[0] = 0;
- nln += 2;
- return nln;
-}
static nserror
llcache_process_metadata(llcache_object *object)
@@ -1109,10 +1088,10 @@ llcache_process_metadata(llcache_object *object)
nsurl *metadataurl;
unsigned int line;
uint8_t *end;
- uint8_t *ln;
- uint8_t *nln;
- int num_headers;
- int hloop;
+ char *ln;
+ int lnsize;
+ size_t num_headers;
+ size_t hloop;
/* attempt to retrieve object metadata from the cache */
res = guit->llcache->meta(object->url, &metadata, &metadatalen);
@@ -1123,12 +1102,13 @@ llcache_process_metadata(llcache_object *object)
/* metadata line 1 is the url the metadata referrs to */
line = 1;
- ln = metadata;
- nln = crlf_line(ln, end);
- if (nln == NULL)
+ ln = (char *)metadata;
+ lnsize = strlen(ln);
+
+ if (lnsize < 7)
goto format_error;
- res = nsurl_create((const char *)ln, &metadataurl);
+ res = nsurl_create(ln, &metadataurl);
if (res != NSERROR_OK) {
free(metadata);
return res;
@@ -1138,7 +1118,7 @@ llcache_process_metadata(llcache_object *object)
/* backing store returned the wrong object for the
* request. This may occour if the backing store had
* a collision in its stoage method. We cope with this
- * buy simply skipping caching of this object.
+ * by simply skipping caching of this object.
*/
LOG(("Got metadata for %s instead of %s",
@@ -1153,33 +1133,35 @@ llcache_process_metadata(llcache_object *object)
}
nsurl_unref(metadataurl);
+
/* metadata line 2 is the objects length */
line = 2;
- ln = nln;
- nln = crlf_line(ln, end);
- if (nln == NULL)
- goto format_error;
- if (sscanf((char *)ln, "%llu", (long long unsigned int *)&object->source_len) != 1)
+ ln += lnsize + 1;
+ lnsize = strlen(ln);
+
+ if ((lnsize < 1) ||
+ (sscanf(ln, "%zu", &object->source_len) != 1))
goto format_error;
object->source_alloc = object->source_len;
+
/* metadata line 3 is the number of headers */
line = 3;
- ln = nln;
- nln = crlf_line(ln, end);
- if (nln == NULL)
- goto format_error;
- if (sscanf((char *)ln, "%d", &num_headers) != 1)
+ ln += lnsize + 1;
+ lnsize = strlen(ln);
+
+ if ((lnsize < 1) ||
+ (sscanf(ln, "%zu", &num_headers) != 1))
goto format_error;
+
/* read headers */
for (hloop = 0 ; hloop < num_headers; hloop++) {
line++;
- ln = nln;
- nln = crlf_line(ln, end);
- if (nln == NULL)
- goto format_error;
- res = llcache_fetch_process_header(object, ln, (nln - ln) - 2);
+ ln += lnsize + 1;
+ lnsize = strlen(ln);
+
+ res = llcache_fetch_process_header(object, (uint8_t *)ln, lnsize);
if (res != NSERROR_OK) {
free(metadata);
return res;
@@ -1963,15 +1945,15 @@ llcache_serialise_metadata(llcache_object *object,
unsigned int hloop;
int use;
- allocsize = 10 + 2; /* object length */
+ allocsize = 10 + 1; /* object length */
- allocsize += 10 + 2; /* space for number of header entries */
+ allocsize += 10 + 1; /* space for number of header entries */
- allocsize += nsurl_length(object->url) + 2;
+ allocsize += nsurl_length(object->url) + 1;
for (hloop = 0 ; hloop < object->num_headers ; hloop++) {
allocsize += strlen(object->headers[hloop].name) + 1;
- allocsize += strlen(object->headers[hloop].value) + 2;
+ allocsize += strlen(object->headers[hloop].value) + 1;
}
data = malloc(allocsize);
@@ -1983,21 +1965,21 @@ llcache_serialise_metadata(llcache_object *object,
datasize = allocsize;
/* the url, used for checking for collisions */
- use = snprintf(op, datasize, "%s\r\n", nsurl_access(object->url));
+ use = snprintf(op, datasize, "%s%c", nsurl_access(object->url), 0);
if (use > datasize)
goto overflow;
op += use;
datasize -= use;
/* object size */
- use = snprintf(op, datasize, "%llu\r\n", (unsigned long long)object->source_len);
+ use = snprintf(op, datasize, "%zu%c", object->source_len, 0);
if (use > datasize)
goto overflow;
op += use;
datasize -= use;
/* number of headers */
- use = snprintf(op, datasize, "%d\r\n", (unsigned int)object->num_headers);
+ use = snprintf(op, datasize, "%zu%c", object->num_headers, 0);
if (use > datasize)
goto overflow;
op += use;
@@ -2006,9 +1988,10 @@ llcache_serialise_metadata(llcache_object *object,
/* headers */
for (hloop = 0 ; hloop < object->num_headers ; hloop++) {
use = snprintf(op, datasize,
- "%s:%s\r\n",
+ "%s:%s%c",
object->headers[hloop].name,
- object->headers[hloop].value);
+ object->headers[hloop].value,
+ 0);
if (use > datasize)
goto overflow;
op += use;
-----------------------------------------------------------------------
Summary of changes:
content/llcache.c | 101 ++++++++++++++++++++++-------------------------------
1 files changed, 42 insertions(+), 59 deletions(-)
diff --git a/content/llcache.c b/content/llcache.c
index 1b354b5..fa886be 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -27,12 +27,12 @@
* \todo add backing store initialisation to set storage parameters like location and size limits.
* \todo implement expiry from backing store
* \todo make the reference backing store have an index to improve performance
- * \todo make the reference backing store have a more efficient metadata store.
+ * \todo make the reference backing store have a more efficient metadata store.
* \todo make the reference backing store cope with filesystems that have filename length limits and directory entry count limits
* \todo make backing store size bounded by configuration
* \todo support mmaped retrieve
- * \todo store metadata in a more easily handled format (null termineted)
* \todo make metadata buffer owned by backing store (avoid allocation and freeing)
+ * \todo instrument and (auto)tune
* \todo turn llcache debugging off
*/
@@ -1037,8 +1037,8 @@ static nserror llcache_object_clone_cache_data(llcache_object *source,
* \param list List to remove from
* \return NSERROR_OK
*/
-static nserror llcache_object_remove_from_list(llcache_object *object,
- llcache_object **list)
+static nserror
+llcache_object_remove_from_list(llcache_object *object, llcache_object **list)
{
if (object == *list)
*list = object->next;
@@ -1061,8 +1061,7 @@ static nserror llcache_object_remove_from_list(llcache_object *object,
* @param object the object to operate on.
* @return apropriate error code.
*/
-static nserror
-llcache_persist_retrieve(llcache_object *object)
+static nserror llcache_persist_retrieve(llcache_object *object)
{
/* ensure the source data is present if necessary */
if ((object->source_data != NULL) ||
@@ -1079,26 +1078,6 @@ llcache_persist_retrieve(llcache_object *object)
&object->source_len);
}
-/**
- * find and null terminate a crlf terminated line.
- *
- * @param data the beginning of the data to search.
- * @param end the end of the data.
- * @return pointer to the next line or NULL if the end of input was reached.
- */
-static uint8_t *crlf_line(uint8_t *data, uint8_t *end)
-{
- uint8_t *nln = data;
- while ((nln < end) && ((nln[0] != 13) || (nln[1] != 10) ))
- nln++;
-
- if (nln == end)
- return NULL;
-
- nln[0] = 0;
- nln += 2;
- return nln;
-}
static nserror
llcache_process_metadata(llcache_object *object)
@@ -1109,10 +1088,10 @@ llcache_process_metadata(llcache_object *object)
nsurl *metadataurl;
unsigned int line;
uint8_t *end;
- uint8_t *ln;
- uint8_t *nln;
- int num_headers;
- int hloop;
+ char *ln;
+ int lnsize;
+ size_t num_headers;
+ size_t hloop;
/* attempt to retrieve object metadata from the cache */
res = guit->llcache->meta(object->url, &metadata, &metadatalen);
@@ -1123,12 +1102,13 @@ llcache_process_metadata(llcache_object *object)
/* metadata line 1 is the url the metadata referrs to */
line = 1;
- ln = metadata;
- nln = crlf_line(ln, end);
- if (nln == NULL)
+ ln = (char *)metadata;
+ lnsize = strlen(ln);
+
+ if (lnsize < 7)
goto format_error;
- res = nsurl_create((const char *)ln, &metadataurl);
+ res = nsurl_create(ln, &metadataurl);
if (res != NSERROR_OK) {
free(metadata);
return res;
@@ -1138,7 +1118,7 @@ llcache_process_metadata(llcache_object *object)
/* backing store returned the wrong object for the
* request. This may occour if the backing store had
* a collision in its stoage method. We cope with this
- * buy simply skipping caching of this object.
+ * by simply skipping caching of this object.
*/
LOG(("Got metadata for %s instead of %s",
@@ -1153,33 +1133,35 @@ llcache_process_metadata(llcache_object *object)
}
nsurl_unref(metadataurl);
+
/* metadata line 2 is the objects length */
line = 2;
- ln = nln;
- nln = crlf_line(ln, end);
- if (nln == NULL)
- goto format_error;
- if (sscanf((char *)ln, "%llu", (long long unsigned int *)&object->source_len) != 1)
+ ln += lnsize + 1;
+ lnsize = strlen(ln);
+
+ if ((lnsize < 1) ||
+ (sscanf(ln, "%zu", &object->source_len) != 1))
goto format_error;
object->source_alloc = object->source_len;
+
/* metadata line 3 is the number of headers */
line = 3;
- ln = nln;
- nln = crlf_line(ln, end);
- if (nln == NULL)
- goto format_error;
- if (sscanf((char *)ln, "%d", &num_headers) != 1)
+ ln += lnsize + 1;
+ lnsize = strlen(ln);
+
+ if ((lnsize < 1) ||
+ (sscanf(ln, "%zu", &num_headers) != 1))
goto format_error;
+
/* read headers */
for (hloop = 0 ; hloop < num_headers; hloop++) {
line++;
- ln = nln;
- nln = crlf_line(ln, end);
- if (nln == NULL)
- goto format_error;
- res = llcache_fetch_process_header(object, ln, (nln - ln) - 2);
+ ln += lnsize + 1;
+ lnsize = strlen(ln);
+
+ res = llcache_fetch_process_header(object, (uint8_t *)ln, lnsize);
if (res != NSERROR_OK) {
free(metadata);
return res;
@@ -1963,15 +1945,15 @@ llcache_serialise_metadata(llcache_object *object,
unsigned int hloop;
int use;
- allocsize = 10 + 2; /* object length */
+ allocsize = 10 + 1; /* object length */
- allocsize += 10 + 2; /* space for number of header entries */
+ allocsize += 10 + 1; /* space for number of header entries */
- allocsize += nsurl_length(object->url) + 2;
+ allocsize += nsurl_length(object->url) + 1;
for (hloop = 0 ; hloop < object->num_headers ; hloop++) {
allocsize += strlen(object->headers[hloop].name) + 1;
- allocsize += strlen(object->headers[hloop].value) + 2;
+ allocsize += strlen(object->headers[hloop].value) + 1;
}
data = malloc(allocsize);
@@ -1983,21 +1965,21 @@ llcache_serialise_metadata(llcache_object *object,
datasize = allocsize;
/* the url, used for checking for collisions */
- use = snprintf(op, datasize, "%s\r\n", nsurl_access(object->url));
+ use = snprintf(op, datasize, "%s%c", nsurl_access(object->url), 0);
if (use > datasize)
goto overflow;
op += use;
datasize -= use;
/* object size */
- use = snprintf(op, datasize, "%llu\r\n", (unsigned long long)object->source_len);
+ use = snprintf(op, datasize, "%zu%c", object->source_len, 0);
if (use > datasize)
goto overflow;
op += use;
datasize -= use;
/* number of headers */
- use = snprintf(op, datasize, "%d\r\n", (unsigned int)object->num_headers);
+ use = snprintf(op, datasize, "%zu%c", object->num_headers, 0);
if (use > datasize)
goto overflow;
op += use;
@@ -2006,9 +1988,10 @@ llcache_serialise_metadata(llcache_object *object,
/* headers */
for (hloop = 0 ; hloop < object->num_headers ; hloop++) {
use = snprintf(op, datasize,
- "%s:%s\r\n",
+ "%s:%s%c",
object->headers[hloop].name,
- object->headers[hloop].value);
+ object->headers[hloop].value,
+ 0);
if (use > datasize)
goto overflow;
op += use;
--
NetSurf Browser
8 years, 11 months
netsurf: branch vince/disccache updated. release/3.0-1131-g49fb39f
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/49fb39fc4535aaba2a50f...
...commit http://git.netsurf-browser.org/netsurf.git/commit/49fb39fc4535aaba2a50f91...
...tree http://git.netsurf-browser.org/netsurf.git/tree/49fb39fc4535aaba2a50f911a...
The branch, vince/disccache has been updated
via 49fb39fc4535aaba2a50f911a73183b46a2f3812 (commit)
from f7836a172060e35c90afbbeb610efbc1758b607c (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=49fb39fc4535aaba2a5...
commit 49fb39fc4535aaba2a50f911a73183b46a2f3812
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
add todo list so i do not forget things
diff --git a/content/llcache.c b/content/llcache.c
index 440e3dd..1b354b5 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -22,6 +22,18 @@
* This is the implementation of the low level cache. This cache
* stores source objects in memory and may use a persistant backing
* store to extend their lifetime.
+ *
+ * \todo fix writeout conditions and ordering
+ * \todo add backing store initialisation to set storage parameters like location and size limits.
+ * \todo implement expiry from backing store
+ * \todo make the reference backing store have an index to improve performance
+ * \todo make the reference backing store have a more efficient metadata store.
+ * \todo make the reference backing store cope with filesystems that have filename length limits and directory entry count limits
+ * \todo make backing store size bounded by configuration
+ * \todo support mmaped retrieve
+ * \todo store metadata in a more easily handled format (null termineted)
+ * \todo make metadata buffer owned by backing store (avoid allocation and freeing)
+ * \todo turn llcache debugging off
*/
#include <stdlib.h>
-----------------------------------------------------------------------
Summary of changes:
content/llcache.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/content/llcache.c b/content/llcache.c
index 440e3dd..1b354b5 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -22,6 +22,18 @@
* This is the implementation of the low level cache. This cache
* stores source objects in memory and may use a persistant backing
* store to extend their lifetime.
+ *
+ * \todo fix writeout conditions and ordering
+ * \todo add backing store initialisation to set storage parameters like location and size limits.
+ * \todo implement expiry from backing store
+ * \todo make the reference backing store have an index to improve performance
+ * \todo make the reference backing store have a more efficient metadata store.
+ * \todo make the reference backing store cope with filesystems that have filename length limits and directory entry count limits
+ * \todo make backing store size bounded by configuration
+ * \todo support mmaped retrieve
+ * \todo store metadata in a more easily handled format (null termineted)
+ * \todo make metadata buffer owned by backing store (avoid allocation and freeing)
+ * \todo turn llcache debugging off
*/
#include <stdlib.h>
--
NetSurf Browser
8 years, 11 months
netsurf: branch vince/disccache updated. release/3.0-1130-gf7836a1
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/f7836a172060e35c90afb...
...commit http://git.netsurf-browser.org/netsurf.git/commit/f7836a172060e35c90afbbe...
...tree http://git.netsurf-browser.org/netsurf.git/tree/f7836a172060e35c90afbbeb6...
The branch, vince/disccache has been updated
via f7836a172060e35c90afbbeb610efbc1758b607c (commit)
from 0c94b51c89b57ad7921ea3d670887de751016714 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=f7836a172060e35c90a...
commit f7836a172060e35c90afbbeb610efbc1758b607c
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
fix metadata retrival
diff --git a/content/llcache.c b/content/llcache.c
index 9f9b2ed..440e3dd 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -1047,7 +1047,7 @@ static nserror llcache_object_remove_from_list(llcache_object *object,
* source data.
*
* @param object the object to operate on.
- *
+ * @return apropriate error code.
*/
static nserror
llcache_persist_retrieve(llcache_object *object)
@@ -1067,6 +1067,13 @@ llcache_persist_retrieve(llcache_object *object)
&object->source_len);
}
+/**
+ * find and null terminate a crlf terminated line.
+ *
+ * @param data the beginning of the data to search.
+ * @param end the end of the data.
+ * @return pointer to the next line or NULL if the end of input was reached.
+ */
static uint8_t *crlf_line(uint8_t *data, uint8_t *end)
{
uint8_t *nln = data;
@@ -1088,9 +1095,12 @@ llcache_process_metadata(llcache_object *object)
uint8_t *metadata = NULL;
size_t metadatalen = 0;
nsurl *metadataurl;
+ unsigned int line;
uint8_t *end;
uint8_t *ln;
uint8_t *nln;
+ int num_headers;
+ int hloop;
/* attempt to retrieve object metadata from the cache */
res = guit->llcache->meta(object->url, &metadata, &metadatalen);
@@ -1098,8 +1108,13 @@ llcache_process_metadata(llcache_object *object)
return res;
end = metadata + metadatalen;
+
+ /* metadata line 1 is the url the metadata referrs to */
+ line = 1;
ln = metadata;
nln = crlf_line(ln, end);
+ if (nln == NULL)
+ goto format_error;
res = nsurl_create((const char *)ln, &metadataurl);
if (res != NSERROR_OK) {
@@ -1122,21 +1137,55 @@ llcache_process_metadata(llcache_object *object)
free(metadata);
- return NSERROR_NOT_FOUND;
+ return NSERROR_BAD_URL;
}
+ nsurl_unref(metadataurl);
+ /* metadata line 2 is the objects length */
+ line = 2;
+ ln = nln;
+ nln = crlf_line(ln, end);
+ if (nln == NULL)
+ goto format_error;
+ if (sscanf((char *)ln, "%llu", (long long unsigned int *)&object->source_len) != 1)
+ goto format_error;
+ object->source_alloc = object->source_len;
-
- nsurl_unref(metadataurl);
+ /* metadata line 3 is the number of headers */
+ line = 3;
+ ln = nln;
+ nln = crlf_line(ln, end);
+ if (nln == NULL)
+ goto format_error;
+ if (sscanf((char *)ln, "%d", &num_headers) != 1)
+ goto format_error;
+
+ /* read headers */
+ for (hloop = 0 ; hloop < num_headers; hloop++) {
+ line++;
+ ln = nln;
+ nln = crlf_line(ln, end);
+ if (nln == NULL)
+ goto format_error;
+ res = llcache_fetch_process_header(object, ln, (nln - ln) - 2);
+ if (res != NSERROR_OK) {
+ free(metadata);
+ return res;
+ }
+ }
free(metadata);
- object->source_alloc = object->source_len;
-
- /* metadata says object stored in backing store */
+ /* object stored in backing store */
object->store_state = LLCACHE_STORE_DISC;
- return NSERROR_NOT_FOUND;
+ return NSERROR_OK;
+
+format_error:
+ LOG(("metadata error on line %d\n", line));
+ free(metadata);
+ return NSERROR_INVALID;
+
}
/**
@@ -1922,21 +1971,21 @@ llcache_serialise_metadata(llcache_object *object,
datasize = allocsize;
/* the url, used for checking for collisions */
- use = snprintf(op, datasize, "%s%c%c", nsurl_access(object->url) ,13, 10);
+ use = snprintf(op, datasize, "%s\r\n", nsurl_access(object->url));
if (use > datasize)
goto overflow;
op += use;
datasize -= use;
/* object size */
- use = snprintf(op, datasize, "%d%c%c", (unsigned int)object->source_len, 13, 10);
+ use = snprintf(op, datasize, "%llu\r\n", (unsigned long long)object->source_len);
if (use > datasize)
goto overflow;
op += use;
datasize -= use;
/* number of headers */
- use = snprintf(op, datasize, "%d%c%c", (unsigned int)object->num_headers, 13, 10);
+ use = snprintf(op, datasize, "%d\r\n", (unsigned int)object->num_headers);
if (use > datasize)
goto overflow;
op += use;
@@ -1945,10 +1994,9 @@ llcache_serialise_metadata(llcache_object *object,
/* headers */
for (hloop = 0 ; hloop < object->num_headers ; hloop++) {
use = snprintf(op, datasize,
- "%s:%s%c%c",
+ "%s:%s\r\n",
object->headers[hloop].name,
- object->headers[hloop].value,
- 13, 10);
+ object->headers[hloop].value);
if (use > datasize)
goto overflow;
op += use;
-----------------------------------------------------------------------
Summary of changes:
content/llcache.c | 76 +++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 62 insertions(+), 14 deletions(-)
diff --git a/content/llcache.c b/content/llcache.c
index 9f9b2ed..440e3dd 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -1047,7 +1047,7 @@ static nserror llcache_object_remove_from_list(llcache_object *object,
* source data.
*
* @param object the object to operate on.
- *
+ * @return apropriate error code.
*/
static nserror
llcache_persist_retrieve(llcache_object *object)
@@ -1067,6 +1067,13 @@ llcache_persist_retrieve(llcache_object *object)
&object->source_len);
}
+/**
+ * find and null terminate a crlf terminated line.
+ *
+ * @param data the beginning of the data to search.
+ * @param end the end of the data.
+ * @return pointer to the next line or NULL if the end of input was reached.
+ */
static uint8_t *crlf_line(uint8_t *data, uint8_t *end)
{
uint8_t *nln = data;
@@ -1088,9 +1095,12 @@ llcache_process_metadata(llcache_object *object)
uint8_t *metadata = NULL;
size_t metadatalen = 0;
nsurl *metadataurl;
+ unsigned int line;
uint8_t *end;
uint8_t *ln;
uint8_t *nln;
+ int num_headers;
+ int hloop;
/* attempt to retrieve object metadata from the cache */
res = guit->llcache->meta(object->url, &metadata, &metadatalen);
@@ -1098,8 +1108,13 @@ llcache_process_metadata(llcache_object *object)
return res;
end = metadata + metadatalen;
+
+ /* metadata line 1 is the url the metadata referrs to */
+ line = 1;
ln = metadata;
nln = crlf_line(ln, end);
+ if (nln == NULL)
+ goto format_error;
res = nsurl_create((const char *)ln, &metadataurl);
if (res != NSERROR_OK) {
@@ -1122,21 +1137,55 @@ llcache_process_metadata(llcache_object *object)
free(metadata);
- return NSERROR_NOT_FOUND;
+ return NSERROR_BAD_URL;
}
+ nsurl_unref(metadataurl);
+ /* metadata line 2 is the objects length */
+ line = 2;
+ ln = nln;
+ nln = crlf_line(ln, end);
+ if (nln == NULL)
+ goto format_error;
+ if (sscanf((char *)ln, "%llu", (long long unsigned int *)&object->source_len) != 1)
+ goto format_error;
+ object->source_alloc = object->source_len;
-
- nsurl_unref(metadataurl);
+ /* metadata line 3 is the number of headers */
+ line = 3;
+ ln = nln;
+ nln = crlf_line(ln, end);
+ if (nln == NULL)
+ goto format_error;
+ if (sscanf((char *)ln, "%d", &num_headers) != 1)
+ goto format_error;
+
+ /* read headers */
+ for (hloop = 0 ; hloop < num_headers; hloop++) {
+ line++;
+ ln = nln;
+ nln = crlf_line(ln, end);
+ if (nln == NULL)
+ goto format_error;
+ res = llcache_fetch_process_header(object, ln, (nln - ln) - 2);
+ if (res != NSERROR_OK) {
+ free(metadata);
+ return res;
+ }
+ }
free(metadata);
- object->source_alloc = object->source_len;
-
- /* metadata says object stored in backing store */
+ /* object stored in backing store */
object->store_state = LLCACHE_STORE_DISC;
- return NSERROR_NOT_FOUND;
+ return NSERROR_OK;
+
+format_error:
+ LOG(("metadata error on line %d\n", line));
+ free(metadata);
+ return NSERROR_INVALID;
+
}
/**
@@ -1922,21 +1971,21 @@ llcache_serialise_metadata(llcache_object *object,
datasize = allocsize;
/* the url, used for checking for collisions */
- use = snprintf(op, datasize, "%s%c%c", nsurl_access(object->url) ,13, 10);
+ use = snprintf(op, datasize, "%s\r\n", nsurl_access(object->url));
if (use > datasize)
goto overflow;
op += use;
datasize -= use;
/* object size */
- use = snprintf(op, datasize, "%d%c%c", (unsigned int)object->source_len, 13, 10);
+ use = snprintf(op, datasize, "%llu\r\n", (unsigned long long)object->source_len);
if (use > datasize)
goto overflow;
op += use;
datasize -= use;
/* number of headers */
- use = snprintf(op, datasize, "%d%c%c", (unsigned int)object->num_headers, 13, 10);
+ use = snprintf(op, datasize, "%d\r\n", (unsigned int)object->num_headers);
if (use > datasize)
goto overflow;
op += use;
@@ -1945,10 +1994,9 @@ llcache_serialise_metadata(llcache_object *object,
/* headers */
for (hloop = 0 ; hloop < object->num_headers ; hloop++) {
use = snprintf(op, datasize,
- "%s:%s%c%c",
+ "%s:%s\r\n",
object->headers[hloop].name,
- object->headers[hloop].value,
- 13, 10);
+ object->headers[hloop].value);
if (use > datasize)
goto overflow;
op += use;
--
NetSurf Browser
8 years, 11 months
netsurf: branch vince/disccache updated. release/3.0-1129-g0c94b51
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/0c94b51c89b57ad7921ea...
...commit http://git.netsurf-browser.org/netsurf.git/commit/0c94b51c89b57ad7921ea3d...
...tree http://git.netsurf-browser.org/netsurf.git/tree/0c94b51c89b57ad7921ea3d67...
The branch, vince/disccache has been updated
via 0c94b51c89b57ad7921ea3d670887de751016714 (commit)
from aa9d887887274224af73e0cf3e5173c553d28d88 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=0c94b51c89b57ad7921...
commit 0c94b51c89b57ad7921ea3d670887de751016714
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
fixup url checking
diff --git a/content/llcache.c b/content/llcache.c
index b27bcf6..9f9b2ed 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -1067,18 +1067,22 @@ llcache_persist_retrieve(llcache_object *object)
&object->source_len);
}
-uint8_t *crlf_line(uint8_t *data, uint8_t *end)
+static uint8_t *crlf_line(uint8_t *data, uint8_t *end)
{
uint8_t *nln = data;
while ((nln < end) && ((nln[0] != 13) || (nln[1] != 10) ))
nln++;
+
+ if (nln == end)
+ return NULL;
+
nln[0] = 0;
nln += 2;
return nln;
}
static nserror
-llcache_process_metadata(llcache_object *object, uint8_t *data, size_t datasize)
+llcache_process_metadata(llcache_object *object)
{
nserror res;
uint8_t *metadata = NULL;
@@ -1089,15 +1093,15 @@ llcache_process_metadata(llcache_object *object, uint8_t *data, size_t datasize)
uint8_t *nln;
/* attempt to retrieve object metadata from the cache */
- error = guit->llcache->meta(object->url, &metadata, &metadatalen);
- if (error != NSERROR_OK)
- return error;
+ res = guit->llcache->meta(object->url, &metadata, &metadatalen);
+ if (res != NSERROR_OK)
+ return res;
- end = matadata + metadatalen;
+ end = metadata + metadatalen;
ln = metadata;
nln = crlf_line(ln, end);
- res = metadataurl(ln, &metadataurl);
+ res = nsurl_create((const char *)ln, &metadataurl);
if (res != NSERROR_OK) {
free(metadata);
return res;
@@ -1110,11 +1114,21 @@ llcache_process_metadata(llcache_object *object, uint8_t *data, size_t datasize)
* buy simply skipping caching of this object.
*/
+ LOG(("Got metadata for %s instead of %s",
+ nsurl_access(metadataurl),
+ nsurl_access(object->url)));
+
+ nsurl_unref(metadataurl);
+
free(metadata);
return NSERROR_NOT_FOUND;
}
+
+
+ nsurl_unref(metadataurl);
+
free(metadata);
object->source_alloc = object->source_len;
-----------------------------------------------------------------------
Summary of changes:
content/llcache.c | 28 +++++++++++++++++++++-------
1 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/content/llcache.c b/content/llcache.c
index b27bcf6..9f9b2ed 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -1067,18 +1067,22 @@ llcache_persist_retrieve(llcache_object *object)
&object->source_len);
}
-uint8_t *crlf_line(uint8_t *data, uint8_t *end)
+static uint8_t *crlf_line(uint8_t *data, uint8_t *end)
{
uint8_t *nln = data;
while ((nln < end) && ((nln[0] != 13) || (nln[1] != 10) ))
nln++;
+
+ if (nln == end)
+ return NULL;
+
nln[0] = 0;
nln += 2;
return nln;
}
static nserror
-llcache_process_metadata(llcache_object *object, uint8_t *data, size_t datasize)
+llcache_process_metadata(llcache_object *object)
{
nserror res;
uint8_t *metadata = NULL;
@@ -1089,15 +1093,15 @@ llcache_process_metadata(llcache_object *object, uint8_t *data, size_t datasize)
uint8_t *nln;
/* attempt to retrieve object metadata from the cache */
- error = guit->llcache->meta(object->url, &metadata, &metadatalen);
- if (error != NSERROR_OK)
- return error;
+ res = guit->llcache->meta(object->url, &metadata, &metadatalen);
+ if (res != NSERROR_OK)
+ return res;
- end = matadata + metadatalen;
+ end = metadata + metadatalen;
ln = metadata;
nln = crlf_line(ln, end);
- res = metadataurl(ln, &metadataurl);
+ res = nsurl_create((const char *)ln, &metadataurl);
if (res != NSERROR_OK) {
free(metadata);
return res;
@@ -1110,11 +1114,21 @@ llcache_process_metadata(llcache_object *object, uint8_t *data, size_t datasize)
* buy simply skipping caching of this object.
*/
+ LOG(("Got metadata for %s instead of %s",
+ nsurl_access(metadataurl),
+ nsurl_access(object->url)));
+
+ nsurl_unref(metadataurl);
+
free(metadata);
return NSERROR_NOT_FOUND;
}
+
+
+ nsurl_unref(metadataurl);
+
free(metadata);
object->source_alloc = object->source_len;
--
NetSurf Browser
8 years, 11 months