dovecot-2.2: lib-master: If write() to anvil fails, reconnect to...

dovecot at dovecot.org dovecot at dovecot.org
Wed Mar 11 14:41:02 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/f7b3c923cf4d
changeset: 18324:f7b3c923cf4d
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Mar 11 16:39:24 2015 +0200
description:
lib-master: If write() to anvil fails, reconnect to it.

diffstat:

 src/lib-master/anvil-client.c |  15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diffs (33 lines):

diff -r f8f57dde247d -r f7b3c923cf4d src/lib-master/anvil-client.c
--- a/src/lib-master/anvil-client.c	Wed Mar 11 14:39:52 2015 +0200
+++ b/src/lib-master/anvil-client.c	Wed Mar 11 16:39:24 2015 +0200
@@ -142,9 +142,13 @@
 	client->fd = fd;
 	client->input = i_stream_create_fd(fd, ANVIL_INBUF_SIZE, FALSE);
 	client->output = o_stream_create_fd(fd, (size_t)-1, FALSE);
-	o_stream_set_no_error_handling(client->output, TRUE);
 	client->io = io_add(fd, IO_READ, anvil_input, client);
-	o_stream_nsend_str(client->output, ANVIL_HANDSHAKE);
+	if (o_stream_send_str(client->output, ANVIL_HANDSHAKE) < 0) {
+		i_error("write(%s) failed: %s", client->path,
+			o_stream_get_error(client->output));
+		anvil_reconnect(client);
+		return -1;
+	}
 	return 0;
 }
 
@@ -190,7 +194,12 @@
 	iov[0].iov_len = strlen(cmd);
 	iov[1].iov_base = "\n";
 	iov[1].iov_len = 1;
-	o_stream_nsendv(client->output, iov, 2);
+	if (o_stream_sendv(client->output, iov, 2) < 0) {
+		i_error("write(%s) failed: %s", client->path,
+			o_stream_get_error(client->output));
+		anvil_reconnect(client);
+		return -1;
+	}
 	return 0;
 }
 


More information about the dovecot-cvs mailing list