From 5899f6c16ea30456c9d4fd8dd2cffd4396d95b5c Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Tue, 3 Jun 2014 22:30:04 +0100 Subject: turn off debugging and add some comments and todo from dsilvers --- content/fs_backing_store.c | 17 +++++++++-------- content/llcache.c | 16 +++++++++------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/content/fs_backing_store.c b/content/fs_backing_store.c index af93d6066..43d902fd3 100644 --- a/content/fs_backing_store.c +++ b/content/fs_backing_store.c @@ -192,7 +192,7 @@ remove_store_entry(struct store_state *state, state->last_entry--; if (sei == state->last_entry) { - /* the removed entry was the last one, how conveniant */ + /* the removed entry was the last one, how convenient */ *bse = &state->entries[sei]; } else { /* need to swap entries */ @@ -318,7 +318,7 @@ store_fname(struct store_state *state, break; default: - assert(false); + assert("Invalid path depth in store_fname()" == NULL); } return fname; @@ -516,7 +516,7 @@ get_store_entry(struct store_state *state, nsurl *url, struct store_entry **bse) * * @param url The value used as the unique key to search entries for. * @param bse Pointer used to return value. - * @return NSERROR_OK and bse updated on succes or NSERROR_NOT_FOUND + * @return NSERROR_OK and \a bse updated on success or NSERROR_NOT_FOUND * if no entry coresponds to the url. */ static nserror @@ -625,6 +625,7 @@ store_open(struct store_state *state, return -1; } + /** @todo mkdir only on write flag */ /* ensure path to file is usable */ ret = filepath_mkdir_all(fname); if (ret != NSERROR_OK) { @@ -693,6 +694,8 @@ build_entrymap(struct store_state *state) /** * Write filesystem entries to file. * + * @todo consider atomic replace using rename. + * * @param state The backing store state to read the entries from. * @return NSERROR_OK on sucess or error code on faliure. */ @@ -723,7 +726,7 @@ static nserror write_entries(struct store_state *state) state->last_entry * sizeof(struct store_entry)); close(fd); if (written < 0) { - /* TODO: Delete the file? */ + /** @todo Delete the file? */ return NSERROR_SAVE_FAILED; } @@ -908,7 +911,6 @@ read_control(struct store_state *state) /* second line is log2 max number of entries */ if (fscanf(fcontrol, "%u", &entrybits) != 1) { - LOG(("c")); goto control_error; } if (fgetc(fcontrol) != 0) { @@ -917,7 +919,6 @@ read_control(struct store_state *state) /* second line is log2 size of address hash */ if (fscanf(fcontrol, "%u", &addrbits) != 1) { - LOG(("d")); goto control_error; } if (fgetc(fcontrol) != 0) { @@ -1115,8 +1116,8 @@ store(nsurl *url, written = write(fd, data, datalen); close(fd); - if (written < 0) { - /* TODO: Delete the file? */ + if (written < datalen) { + /** @todo Delete the file? */ return NSERROR_SAVE_FAILED; } diff --git a/content/llcache.c b/content/llcache.c index f984703dd..b241ab22b 100644 --- a/content/llcache.c +++ b/content/llcache.c @@ -29,8 +29,6 @@ * * \todo instrument and (auto)tune * - * \todo turn llcache debugging off - * */ #include @@ -52,8 +50,8 @@ #include "content/urldb.h" /** Define to enable tracing of llcache operations. */ -//#undef LLCACHE_TRACE -#define LLCACHE_TRACE 1 +#undef LLCACHE_TRACE +//#define LLCACHE_TRACE 1 #ifdef LLCACHE_TRACE #define LLCACHE_LOG(x) LOG(x) @@ -2182,7 +2180,9 @@ build_candidate_list(struct llcache_object ***lst_out, int *lst_len_out) int lst_len = 0; int remaining_lifetime; - lst = calloc(512, sizeof(struct llcache_object *)); +#define MAX_PERSIST_PER_RUN 512 + + lst = calloc(MAX_PERSIST_PER_RUN, sizeof(struct llcache_object *)); if (lst == NULL) return NSERROR_NOMEM; @@ -2202,7 +2202,7 @@ build_candidate_list(struct llcache_object ***lst_out, int *lst_len_out) (remaining_lifetime > llcache->minimum_lifetime)) { lst[lst_len] = object; lst_len++; - if (lst_len == 512) + if (lst_len == MAX_PERSIST_PER_RUN) break; } } @@ -2212,11 +2212,13 @@ build_candidate_list(struct llcache_object ***lst_out, int *lst_len_out) return NSERROR_NOT_FOUND; } - /* sort list here */ + /** \todo sort list here */ *lst_len_out = lst_len; *lst_out = lst; +#undef MAX_PERSIST_PER_RUN + return NSERROR_OK; } -- cgit v1.2.3