altos: Flush log when full
authorKeith Packard <keithp@keithp.com>
Sun, 16 Jan 2011 06:42:38 +0000 (22:42 -0800)
committerKeith Packard <keithp@keithp.com>
Sun, 16 Jan 2011 22:34:54 +0000 (14:34 -0800)
When the log storage is full, make sure any pending writes are flushed
out so that the last bit isn't lost.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/ao_log.c

index 8666482b51ab6da82b086cdf9b5c1423cc26b957..fa0725502332fe10b884adff4090d37e6fb8ad6d 100644 (file)
@@ -42,8 +42,8 @@ ao_log_data(__xdata struct ao_log_record *log) __reentrant
        log->csum = 0;
        log->csum = ao_log_csum((__xdata uint8_t *) log);
        ao_mutex_get(&ao_log_mutex); {
        log->csum = 0;
        log->csum = ao_log_csum((__xdata uint8_t *) log);
        ao_mutex_get(&ao_log_mutex); {
-               if (ao_log_current_pos >= ao_log_end_pos)
-                       ao_log_running = 0;
+               if (ao_log_current_pos >= ao_log_end_pos && ao_log_running)
+                       ao_log_stop();
                if (ao_log_running) {
                        wrote = 1;
                        ao_storage_write(ao_log_current_pos,
                if (ao_log_running) {
                        wrote = 1;
                        ao_storage_write(ao_log_current_pos,