From 6523ba44a984154b625875dde4997d4363f2b8e7 Mon Sep 17 00:00:00 2001 From: Miika Pekkarinen Date: Sat, 26 Aug 2006 09:24:20 +0000 Subject: [PATCH] Fixed performance problems when initializing tagcache. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10754 a1c6a512-1295-4272-9138-f99709370657 --- apps/tagcache.c | 14 ++++++++++++++ firmware/common/dircache.c | 3 ++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/apps/tagcache.c b/apps/tagcache.c index a5718c6829..d66722e08c 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c @@ -2585,6 +2585,7 @@ static bool parse_changelog_line(int masterfd, const char *buf) bool tagcache_import_changelog(void) { struct master_header myhdr; + struct tagcache_header tch; int clfd, masterfd; char buf[512]; int pos = 0; @@ -2610,6 +2611,8 @@ bool tagcache_import_changelog(void) write_lock++; + filenametag_fd = open_tag_fd(&tch, tag_filename, false); + /* Fast readline */ while ( 1 ) { @@ -2649,6 +2652,9 @@ bool tagcache_import_changelog(void) close(clfd); close(masterfd); + if (filenametag_fd >= 0) + close(filenametag_fd); + write_lock--; update_current_serial(current_serial); @@ -3114,6 +3120,8 @@ static bool load_tagcache(void) else # endif { + +# if 0 /* Maybe we could enable this for flash players. Too slow otherwise. */ /* Check if entry has been removed. */ if (global_settings.tagcache_autoupdate) { @@ -3129,6 +3137,7 @@ static bool load_tagcache(void) } close(testfd); } +# endif } continue ; @@ -3287,6 +3296,11 @@ static void build_tagcache(void) logf("updating tagcache"); +#ifdef HAVE_DIRCACHE + while (dircache_is_initializing()) + sleep(1); +#endif + cachefd = open(TAGCACHE_FILE_TEMP, O_RDONLY); if (cachefd >= 0) { diff --git a/firmware/common/dircache.c b/firmware/common/dircache.c index d0fdba06af..17033e1827 100644 --- a/firmware/common/dircache.c +++ b/firmware/common/dircache.c @@ -567,6 +567,7 @@ static int dircache_do_rebuild(void) memset(fd_bindings, 0, sizeof(fd_bindings)); for (i = 0; i < fdbind_idx; i++) dircache_bind(fdbind_cache[i].fd, fdbind_cache[i].path); + fdbind_idx = 0; if (thread_enabled) { @@ -641,7 +642,7 @@ int dircache_build(int last_size) if (last_size > DIRCACHE_RESERVE && last_size < DIRCACHE_LIMIT ) { allocated_size = last_size + DIRCACHE_RESERVE; - dircache_root = (struct dircache_entry *)buffer_alloc(allocated_size); + dircache_root = buffer_alloc(allocated_size); thread_enabled = true; /* Start a transparent rebuild. */