diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/common/dircache.c | 23 |
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, | 1215 | static bool is_disable_msg_pending(void) |
1215 | * the dircache became invalid but functions could be called before the | ||
1216 | * dircache thread processes the message */ | ||
1217 | static 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 | ||
1227 | DIR_CACHED* opendir_cached(const char* name) | 1220 | DIR_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); |