changeset 10627:5e50d5597474 HEAD

dict proxy: Iteration failure wasn't passed to dict client.
author Timo Sirainen <tss@iki.fi>
date Tue, 02 Feb 2010 15:18:25 +0200
parents 9a5f3e3b0197
children 568c437ad951
files src/dict/dict-commands.c src/lib-dict/dict-client.c
diffstat 2 files changed, 15 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/dict/dict-commands.c	Tue Feb 02 15:00:15 2010 +0200
+++ b/src/dict/dict-commands.c	Tue Feb 02 15:18:25 2010 +0200
@@ -70,7 +70,12 @@
 		/* finished iterating */
 		o_stream_unset_flush_callback(conn->output);
 		dict_iterate_deinit(&conn->iter_ctx);
-		o_stream_send(conn->output, "\n", 1);
+
+		str_truncate(str, 0);
+		if (ret < 0)
+			str_append_c(str, DICT_PROTOCOL_REPLY_FAIL);
+		str_append_c(str, '\n');
+		o_stream_send(conn->output, str_data(str), str_len(str));
 	}
 	o_stream_uncork(conn->output);
 	return ret <= 0 ? 1 : 0;
--- a/src/lib-dict/dict-client.c	Tue Feb 02 15:00:15 2010 +0200
+++ b/src/lib-dict/dict-client.c	Tue Feb 02 15:18:25 2010 +0200
@@ -517,10 +517,16 @@
 	/* line contains key \t value */
 	p_clear(ctx->pool);
 
-	if (*line != DICT_PROTOCOL_REPLY_OK)
+	switch (*line) {
+	case DICT_PROTOCOL_REPLY_OK:
+		value = strchr(++line, '\t');
+		break;
+	case DICT_PROTOCOL_REPLY_FAIL:
+		return -1;
+	default:
 		value = NULL;
-	else
-		value = strchr(++line, '\t');
+		break;
+	}
 	if (value == NULL) {
 		/* broken protocol */
 		i_error("dict client (%s) sent broken reply", dict->path);