summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmaury Pouly <pamaury@rockbox.org>2010-05-21 12:50:50 +0000
committerAmaury Pouly <pamaury@rockbox.org>2010-05-21 12:50:50 +0000
commitb8ad90aba84ab3cc75cb2405b2e455c526f61c38 (patch)
tree35a5a2851a4b182685caebb63c7dc5334cd63971
parent7d8c02d1059f74eb88d175509fd95b34d0c9b0dd (diff)
downloadrockbox-b8ad90aba84ab3cc75cb2405b2e455c526f61c38.tar.gz
rockbox-b8ad90aba84ab3cc75cb2405b2e455c526f61c38.zip
dircache:
- fix check_event_queue to use queue_peek and not mess message order - change check_dircache_state to a more modest check to avoid messing up dircache state git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26228 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/common/dircache.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/firmware/common/dircache.c b/firmware/common/dircache.c
index 4a033f5f83..f8365e1137 100644
--- a/firmware/common/dircache.c
+++ b/firmware/common/dircache.c
@@ -155,7 +155,9 @@ static bool check_event_queue(void)
155{ 155{
156 struct queue_event ev; 156 struct queue_event ev;
157 157
158 queue_wait_w_tmo(&dircache_queue, &ev, 0); 158 if(!queue_peek(&dircache_queue, &ev))
159 return false;
160
159 switch (ev.id) 161 switch (ev.id)
160 { 162 {
161 case DIRCACHE_STOP: 163 case DIRCACHE_STOP:
@@ -163,8 +165,6 @@ static bool check_event_queue(void)
163#ifdef HAVE_HOTSWAP 165#ifdef HAVE_HOTSWAP
164 case SYS_FS_CHANGED: 166 case SYS_FS_CHANGED:
165#endif 167#endif
166 /* Put the event back into the queue. */
167 queue_post(&dircache_queue, ev.id, ev.data);
168 return true; 168 return true;
169 } 169 }
170 170
@@ -1092,6 +1092,7 @@ void dircache_mkdir(const char *path)
1092 if (block_until_ready()) 1092 if (block_until_ready())
1093 return ; 1093 return ;
1094 1094
1095
1095 logf("mkdir: %s", path); 1096 logf("mkdir: %s", path);
1096 dircache_new_entry(path, ATTR_DIRECTORY); 1097 dircache_new_entry(path, ATTR_DIRECTORY);
1097} 1098}
@@ -1211,17 +1212,9 @@ void dircache_add_file(const char *path, long startcluster)
1211 entry->startcluster = startcluster; 1212 entry->startcluster = startcluster;
1212} 1213}
1213 1214
1214/* Check if dircache state is still valid. With hotswap, on fs changed, 1215static bool is_disable_msg_pending(void)
1215 * the dircache became invalid but functions could be called before the
1216 * dircache thread processes the message */
1217static void check_dircache_state(void)
1218{ 1216{
1219 if(check_event_queue()) 1217 return check_event_queue();
1220 {
1221 /* Keep this coherent with check_event_queue(). Currently, all the
1222 * messages that return true will lead to disable. */
1223 dircache_initialized = false;
1224 }
1225} 1218}
1226 1219
1227DIR_CACHED* opendir_cached(const char* name) 1220DIR_CACHED* opendir_cached(const char* name)
@@ -1248,10 +1241,8 @@ DIR_CACHED* opendir_cached(const char* name)
1248 } 1241 }
1249 1242
1250 pdir->busy = true; 1243 pdir->busy = true;
1251 /* check real dircache state */
1252 check_dircache_state();
1253 1244
1254 if (!dircache_initialized) 1245 if (!dircache_initialized || is_disable_msg_pending())
1255 { 1246 {
1256 pdir->internal_entry = NULL; 1247 pdir->internal_entry = NULL;
1257 pdir->regulardir = opendir_uncached(name); 1248 pdir->regulardir = opendir_uncached(name);