changeset 19200:471383fa1284

dict-client: Improved broken iterate reply logging.
author Timo Sirainen <tss@iki.fi>
date Wed, 23 Sep 2015 23:00:30 +0300
parents bc9b61338985
children b8d2cbd6583b
files src/lib-dict/dict-client.c
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-dict/dict-client.c	Wed Sep 23 22:59:55 2015 +0300
+++ b/src/lib-dict/dict-client.c	Wed Sep 23 23:00:30 2015 +0300
@@ -651,7 +651,7 @@
 	struct client_dict_iterate_context *ctx =
 		(struct client_dict_iterate_context *)_ctx;
 	struct client_dict *dict = (struct client_dict *)_ctx->dict;
-	char *line, *value;
+	char *line, *key, *value;
 
 	if (ctx->failed)
 		return FALSE;
@@ -674,24 +674,26 @@
 
 	switch (*line) {
 	case DICT_PROTOCOL_REPLY_OK:
-		value = strchr(++line, '\t');
+		key = line+1;
+		value = strchr(key, '\t');
 		break;
 	case DICT_PROTOCOL_REPLY_FAIL:
 		ctx->failed = TRUE;
 		return FALSE;
 	default:
+		key = NULL;
 		value = NULL;
 		break;
 	}
 	if (value == NULL) {
 		/* broken protocol */
-		i_error("dict client (%s) sent broken reply", dict->path);
+		i_error("dict client (%s) sent broken iterate reply: %s", dict->path, line);
 		ctx->failed = TRUE;
 		return FALSE;
 	}
 	*value++ = '\0';
 
-	*key_r = p_strdup(ctx->pool, dict_client_unescape(line));
+	*key_r = p_strdup(ctx->pool, dict_client_unescape(key));
 	*value_r = p_strdup(ctx->pool, dict_client_unescape(value));
 	return TRUE;
 }