summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2017-02-12 07:13:25 -0500
committerMichael Sevakis <jethead71@rockbox.org>2017-02-13 00:46:23 -0500
commitdc22522c2c21f058333e4383d644cb18f355ac76 (patch)
tree5b79ef883bb8bc86416706521362f28498b55b2f
parent0a9f71790bcad2c6ffdc96db59c446fe84336d40 (diff)
downloadrockbox-dc22522c2c21f058333e4383d644cb18f355ac76.tar.gz
rockbox-dc22522c2c21f058333e4383d644cb18f355ac76.zip
Tweak a few tagcache things.
* Take out pointless dircache_search; nothing can be reconstructed with the given info in find_entry_ram(); don't even try there. Path AND index id must be known. Work it out later. * Timed yield must be far more often than once every 1/4 second (?!) * Do better the memory-remaining checks for ramcache load. * Root separator mustn't be doubled up when searching files. Change-Id: I091813f4495f3bd0d0c4672bc674df52343b3e48
-rw-r--r--apps/tagcache.c46
1 files changed, 18 insertions, 28 deletions
diff --git a/apps/tagcache.c b/apps/tagcache.c
index dfab06da20..6b6e4839d5 100644
--- a/apps/tagcache.c
+++ b/apps/tagcache.c
@@ -438,8 +438,8 @@ static bool do_timed_yield(void)
static long wakeup_tick = 0;
if (TIME_AFTER(current_tick, wakeup_tick))
{
- wakeup_tick = current_tick + (HZ/4);
yield();
+ wakeup_tick = current_tick + (HZ/50);
return true;
}
return false;
@@ -471,27 +471,17 @@ static long find_entry_ram(const char *filename)
{
for (int i = last_pos; i < end_pos; i++)
{
- if (tcramcache.hdr->indices[i].flag & FLAG_DIRCACHE)
- {
- int cmp = dircache_fileref_cmp(&tcrc_dcfrefs[i], &dcfref);
- if (cmp > 0)
- {
- if (cmp < 3)
- {
- if (dircache_search(DCS_CACHED_PATH | DCS_UPDATE_FILEREF,
- &dcfref, filename) <= 0)
- return -1;
+ do_timed_yield();
- if (dircache_fileref_cmp(&tcrc_dcfrefs[i], &dcfref) < 3)
- return -1;
- }
+ if (!(tcramcache.hdr->indices[i].flag & FLAG_DIRCACHE))
+ continue;
- last_pos = MAX(0, i - 3);
- return i;
- }
- }
+ int cmp = dircache_fileref_cmp(&tcrc_dcfrefs[i], &dcfref);
+ if (cmp < 3)
+ continue;
- do_timed_yield();
+ last_pos = MAX(0, i - 3);
+ return i;
}
if (last_pos == 0)
@@ -4084,7 +4074,7 @@ static bool load_tagcache(void)
p = TC_ALIGN_PTR(p, &rc);
bytesleft -= rc;
- if (bytesleft <= 0)
+ if (bytesleft < (ssize_t)sizeof(struct tagcache_header))
{
logf("Too big tagcache #10.5");
goto failure;
@@ -4112,17 +4102,11 @@ static bool load_tagcache(void)
p = TC_ALIGN_PTR(p, &rc);
bytesleft -= rc;
- if (bytesleft <= 0)
+ if (bytesleft < (ssize_t)sizeof(struct tagfile_entry))
{
logf("Too big tagcache #10.75");
goto failure;
}
-
- if (bytesleft < (ssize_t)sizeof (struct tagfile_entry))
- {
- logf("Too big tagcache #10.875");
- goto failure;
- }
struct tagfile_entry *fe = (struct tagfile_entry *)p;
off_t pos = lseek(fd, 0, SEEK_CUR);
@@ -4141,6 +4125,12 @@ static bool load_tagcache(void)
if (tag == tag_filename)
{
int idx_id = fe->idx_id; /* gonna clobber tagfile entry */
+ if (idx_id < 0 || idx_id >= tcmh.tch.entry_count)
+ {
+ logf("corrupt tagfile entry (tag: %d)", tag);
+ goto failure;
+ }
+
struct index_entry *idx = &tcramcache.hdr->indices[idx_id];
#ifdef HAVE_DIRCACHE
@@ -4479,7 +4469,7 @@ static bool check_dir(const char *dirname, int add_files)
struct dirinfo info = dir_get_info(dir, entry);
size_t len = strlen(curpath);
- path_append(&curpath[len], PA_SEP_HARD, entry->d_name,
+ path_append(&curpath[len-1], PA_SEP_HARD, entry->d_name,
sizeof (curpath) - len);
processed_dir_count++;