changeset 14930:09fcb43c47a4

lib-settings: Improved error messages when config server disconnects too early.
author Timo Sirainen <tss@iki.fi>
date Mon, 04 Mar 2013 15:18:08 +0200
parents 311371856dcf
children a7928075f0fd
files src/lib-settings/settings-parser.c
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-settings/settings-parser.c	Wed Feb 27 13:07:35 2013 +0200
+++ b/src/lib-settings/settings-parser.c	Mon Mar 04 15:18:08 2013 +0200
@@ -950,8 +950,15 @@
 		if (input->stream_errno != 0) {
 			ctx->error = p_strdup_printf(ctx->parser_pool,
 						     "read() failed: %m");
+		} else if (input->v_offset == 0) {
+			ctx->error = p_strdup_printf(ctx->parser_pool,
+				"read(%s) disconnected before receiving any data",
+				i_stream_get_name(input));
 		} else {
-			ctx->error = "input is missing end-of-settings line";
+			ctx->error = p_strdup_printf(ctx->parser_pool,
+				"read(%s) disconnected before receiving "
+				"end-of-settings line",
+				i_stream_get_name(input));
 		}
 		break;
 	case -2:
@@ -982,6 +989,7 @@
 	}
 
 	input = i_stream_create_fd(fd, max_line_length, TRUE);
+	i_stream_set_name(input, path);
 	ret = settings_parse_stream_read(ctx, input);
 	i_stream_unref(&input);
 
@@ -1071,6 +1079,7 @@
 	(void)close(fd[1]);
 
 	input = i_stream_create_fd(fd[0], (size_t)-1, TRUE);
+	i_stream_set_name(input, bin_path);
 	ret = settings_parse_stream_read(ctx, input);
 	i_stream_destroy(&input);