From e4c0ef35fc40728fe81acf4828147ed1299dacda Mon Sep 17 00:00:00 2001 From: Miika Pekkarinen Date: Wed, 22 Mar 2006 17:09:13 +0000 Subject: [PATCH] Don't stop dircache thread when charger is plugged in/removed. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9193 a1c6a512-1295-4272-9138-f99709370657 --- firmware/common/dircache.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) 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 @@ -135,6 +135,27 @@ static struct dircache_entry* dircache_gen_down(struct dircache_entry *ce) #define MAX_SCAN_DEPTH 16 static struct travel_data dir_recursion[MAX_SCAN_DEPTH]; +/** + * Returns true if there is an event waiting in the queue + * that requires the current operation to be aborted. + */ +static bool check_event_queue(void) +{ + struct event ev; + + queue_wait_w_tmo(&dircache_queue, &ev, 0); + switch (ev.id) + { + case DIRCACHE_STOP: + case SYS_USB_CONNECTED: + /* Put the event back into the queue. */ + queue_post(&dircache_queue, ev.id, ev.data); + return true; + } + + return false; +} + /** * Internal function to iterate a path. */ @@ -145,7 +166,7 @@ static int dircache_scan(struct travel_data *td) if (thread_enabled) { /* Stop if we got an external signal. */ - if (!queue_empty(&dircache_queue)) + if (check_event_queue()) return -6; yield(); }