log->w_off = logger_offset(log, w_off + chunk_len);
}
-static void flush_thread_data(struct file* file, bool log_locked)
+/*
+ * The caller needs to hold log->mutex.
+ */
+static void flush_thread_data(struct file* file)
{
struct logger_writer *writer = file->private_data;
struct logger_log *log = file_get_log(file);
chunk_len = writer->b_off + 1;
writer->b_header.len = chunk_len + writer->tag_len + 2;
- if (!log_locked)
- mutex_lock(&log->mutex);
-
fix_up_readers(log, sizeof(struct logger_entry) + writer->b_header.len);
write_log_data(log, &writer->b_header, writer, chunk_len);
- if (!log_locked)
- mutex_unlock(&log->mutex);
-
writer->b_off = 0;
writer->buffer[0] = '\0';
}
/* flush message from a different thread */
if (writer->b_owner != current && writer->b_off)
- flush_thread_data(file, true);
+ flush_thread_data(file);
count = 0;
/* -1 : leave space for message terminating '\0' */
kfree(reader);
} else {
struct logger_writer *writer = file->private_data;
+ struct logger_log *log = writer->log;
+
bool from_stdio = writer->tag && writer->prio >= 2;
- if (from_stdio && writer->b_off > 0)
- flush_thread_data(file, false);
+ if (from_stdio && writer->b_off > 0) {
+ mutex_lock(&log->mutex);
+ flush_thread_data(file);
+ mutex_unlock(&log->mutex);
+ }
kfree(writer->tag);
kfree(writer->buffer);