From 15285bff6af22f231be0a255e0e2d831a3385b6a Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Thu, 19 Feb 2009 17:57:03 +0100 Subject: [PATCH] Logging: Let log handlers return errno upon error. --- ucw/log-file.c | 4 ++-- ucw/log.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ucw/log-file.c b/ucw/log-file.c index f04e68dc..64528081 100644 --- a/ucw/log-file.c +++ b/ucw/log-file.c @@ -20,6 +20,7 @@ #include #include #include +#include struct file_stream { struct log_stream ls; // ls.name is the current name of the log file @@ -111,8 +112,7 @@ file_handler(struct log_stream *ls, struct log_msg *m) do_log_switch(fs, m->tm); int r = write(fs->fd, m->m, m->m_len); - /* FIXME: check for errors here? */ - return 0; + return ((r < 0) ? errno : 0); } struct log_stream * diff --git a/ucw/log.h b/ucw/log.h index e08609b5..0b1edd9a 100644 --- a/ucw/log.h +++ b/ucw/log.h @@ -39,7 +39,7 @@ struct log_stream { uns use_count; // Number of references to the stream int (*filter)(struct log_stream* ls, struct log_msg *m); // Filter function, return non-zero to discard the message clist substreams; // Pass the message to these streams (simple_list of pointers) - int (*handler)(struct log_stream *ls, struct log_msg *m); // Called to commit the message + int (*handler)(struct log_stream *ls, struct log_msg *m); // Called to commit the message, return 0 for success, errno on error void (*close)(struct log_stream* ls); // Called upon log_close_stream() // Private data of the handler follow }; -- 2.39.2