summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2013-08-16 21:55:09 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2013-08-16 21:59:16 +0200
commitc13f21a4d5c27c638c9f0dedf6d7b1f9bbb4d682 (patch)
treeadb89891d67225cc7a509979b5a2dc062fafe6c4 /firmware
parent630a166a94282d9d0211d6cc77d70b9d384c1d06 (diff)
downloadrockbox-c13f21a4d5c27c638c9f0dedf6d7b1f9bbb4d682.tar.gz
rockbox-c13f21a4d5c27c638c9f0dedf6d7b1f9bbb4d682.zip
Fix logdisk
The code was broken in a subtle but crucial way: storage idle callbacks are oneshot so after the first flush everything would stay in the buffer forever and would never be written to the disk thus resulting into many events being lost. This changed correctly registers the idle callback each time the buffer is not empty. Note that the idle storage code checks if a callback has is in the queue already so we don't register twice. Change-Id: Ifdf331d4b757e05b8a6902bf5926cbc7689f5109
Diffstat (limited to 'firmware')
-rw-r--r--firmware/logf.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/firmware/logf.c b/firmware/logf.c
index e135b0b27f..fadfc9bb13 100644
--- a/firmware/logf.c
+++ b/firmware/logf.c
@@ -273,6 +273,8 @@ static int logdiskf_push(void *userp, unsigned char c)
273 return true; 273 return true;
274} 274}
275 275
276static void flush_buffer(void* data);
277
276void _logdiskf(const char* file, const char level, const char *fmt, ...) 278void _logdiskf(const char* file, const char level, const char *fmt, ...)
277{ 279{
278 280
@@ -296,9 +298,9 @@ void _logdiskf(const char* file, const char level, const char *fmt, ...)
296 298
297 vuprintf(logdiskf_push, NULL, fmt, ap); 299 vuprintf(logdiskf_push, NULL, fmt, ap);
298 va_end(ap); 300 va_end(ap);
299 301 register_storage_idle_func(flush_buffer);
300
301} 302}
303
302static void flush_buffer(void* data) 304static void flush_buffer(void* data)
303{ 305{
304 (void)data; 306 (void)data;
@@ -316,8 +318,4 @@ static void flush_buffer(void* data)
316 logdiskfindex = 0; 318 logdiskfindex = 0;
317} 319}
318 320
319void init_logdiskf()
320{
321 register_storage_idle_func(flush_buffer);
322}
323#endif 321#endif