Fixed performance problems when initializing tagcache.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10754 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Miika Pekkarinen 2006-08-26 09:24:20 +00:00
parent 7c13843805
commit 6523ba44a9
2 changed files with 16 additions and 1 deletions

View file

@ -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)
{

View file

@ -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. */