diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/common/dircache.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/firmware/common/dircache.c b/firmware/common/dircache.c index df68022fcd..4facbb8ab2 100644 --- a/firmware/common/dircache.c +++ b/firmware/common/dircache.c | |||
@@ -136,6 +136,27 @@ static struct dircache_entry* dircache_gen_down(struct dircache_entry *ce) | |||
136 | static struct travel_data dir_recursion[MAX_SCAN_DEPTH]; | 136 | static struct travel_data dir_recursion[MAX_SCAN_DEPTH]; |
137 | 137 | ||
138 | /** | 138 | /** |
139 | * Returns true if there is an event waiting in the queue | ||
140 | * that requires the current operation to be aborted. | ||
141 | */ | ||
142 | static bool check_event_queue(void) | ||
143 | { | ||
144 | struct event ev; | ||
145 | |||
146 | queue_wait_w_tmo(&dircache_queue, &ev, 0); | ||
147 | switch (ev.id) | ||
148 | { | ||
149 | case DIRCACHE_STOP: | ||
150 | case SYS_USB_CONNECTED: | ||
151 | /* Put the event back into the queue. */ | ||
152 | queue_post(&dircache_queue, ev.id, ev.data); | ||
153 | return true; | ||
154 | } | ||
155 | |||
156 | return false; | ||
157 | } | ||
158 | |||
159 | /** | ||
139 | * Internal function to iterate a path. | 160 | * Internal function to iterate a path. |
140 | */ | 161 | */ |
141 | static int dircache_scan(struct travel_data *td) | 162 | static int dircache_scan(struct travel_data *td) |
@@ -145,7 +166,7 @@ static int dircache_scan(struct travel_data *td) | |||
145 | if (thread_enabled) | 166 | if (thread_enabled) |
146 | { | 167 | { |
147 | /* Stop if we got an external signal. */ | 168 | /* Stop if we got an external signal. */ |
148 | if (!queue_empty(&dircache_queue)) | 169 | if (check_event_queue()) |
149 | return -6; | 170 | return -6; |
150 | yield(); | 171 | yield(); |
151 | } | 172 | } |