summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorMiika Pekkarinen <miipekk@ihme.org>2005-10-20 08:33:59 +0000
committerMiika Pekkarinen <miipekk@ihme.org>2005-10-20 08:33:59 +0000
commit4b2aa9830ef0bb79d1089f35a974cd7cfb592422 (patch)
tree14998c2f099614b4b5f5c8c925de9b926aeec160 /firmware
parentabd9f83e92fae22dcb9806deae665b7b303f430d (diff)
downloadrockbox-4b2aa9830ef0bb79d1089f35a974cd7cfb592422.tar.gz
rockbox-4b2aa9830ef0bb79d1089f35a974cd7cfb592422.tar.bz2
rockbox-4b2aa9830ef0bb79d1089f35a974cd7cfb592422.zip
Now correctly interrupting the dircache rebuilding.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7645 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/common/dircache.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/firmware/common/dircache.c b/firmware/common/dircache.c
index ca07a35989..fa24321726 100644
--- a/firmware/common/dircache.c
+++ b/firmware/common/dircache.c
@@ -41,6 +41,7 @@
/* Queue commands. */
#define DIRCACHE_BUILD 1
+#define DIRCACHE_STOP 2
extern char *audiobuf;
@@ -406,6 +407,11 @@ static void dircache_thread(void)
thread_enabled = false;
break ;
+ case DIRCACHE_STOP:
+ logf("Stopped the rebuilding.");
+ dircache_initialized = false;
+ break ;
+
#ifndef SIMULATOR
case SYS_USB_CONNECTED:
usb_acknowledge(SYS_USB_CONNECTED_ACK);
@@ -487,13 +493,28 @@ int dircache_get_cache_size(void)
void dircache_disable(void)
{
int i;
+ bool cache_in_use;
+
+ if (thread_enabled)
+ queue_post(&dircache_queue, DIRCACHE_STOP, 0);
while (thread_enabled)
sleep(1);
dircache_initialized = false;
- for (i = 0; i < MAX_OPEN_DIRS; i++)
- opendirs[i].busy = false;
+ logf("Waiting for cached dirs to release");
+ do {
+ cache_in_use = false;
+ for (i = 0; i < MAX_OPEN_DIRS; i++) {
+ if (!opendirs[i].regulardir && opendirs[i].busy)
+ {
+ cache_in_use = true;
+ sleep(1);
+ break ;
+ }
+ }
+ } while (cache_in_use) ;
+ logf("Cache released");
}
/* --- Directory cache live updating functions --- */