diff netio.c @ 1065:23103e1e9548

Fix error handling for dbclient async connect
author Matt Johnston <matt@ucc.asn.au>
date Tue, 03 Mar 2015 20:53:00 +0800
parents fd3712d1ff7f
children cce03ea8e6eb
line wrap: on
line diff
--- a/netio.c	Mon Mar 02 21:40:06 2015 +0800
+++ b/netio.c	Tue Mar 03 20:53:00 2015 +0800
@@ -104,6 +104,8 @@
 			message.msg_iovlen = iovlen;
 			res = sendmsg(c->sock, &message, MSG_FASTOPEN);
 			if (res < 0 && errno != EINPROGRESS) {
+				m_free(c->errstring);
+				c->errstring = m_strdup(strerror(errno));
 				/* Not entirely sure which kind of errors are normal - 2.6.32 seems to 
 				return EPIPE for any (nonblocking?) sendmsg(). just fall back */
 				TRACE(("sendmsg tcp_fastopen failed, falling back. %s", strerror(errno)));
@@ -124,6 +126,8 @@
 
 		if (res < 0 && errno != EINPROGRESS) {
 			/* failure */
+			m_free(c->errstring);
+			c->errstring = m_strdup(strerror(errno));
 			close(c->sock);
 			c->sock = -1;
 			continue;