comparison 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
comparison
equal deleted inserted replaced
1064:0b365b6a6f08 1065:23103e1e9548
102 int iovlen; /* Linux msg_iovlen is a size_t */ 102 int iovlen; /* Linux msg_iovlen is a size_t */
103 message.msg_iov = packet_queue_to_iovec(c->writequeue, &iovlen); 103 message.msg_iov = packet_queue_to_iovec(c->writequeue, &iovlen);
104 message.msg_iovlen = iovlen; 104 message.msg_iovlen = iovlen;
105 res = sendmsg(c->sock, &message, MSG_FASTOPEN); 105 res = sendmsg(c->sock, &message, MSG_FASTOPEN);
106 if (res < 0 && errno != EINPROGRESS) { 106 if (res < 0 && errno != EINPROGRESS) {
107 m_free(c->errstring);
108 c->errstring = m_strdup(strerror(errno));
107 /* Not entirely sure which kind of errors are normal - 2.6.32 seems to 109 /* Not entirely sure which kind of errors are normal - 2.6.32 seems to
108 return EPIPE for any (nonblocking?) sendmsg(). just fall back */ 110 return EPIPE for any (nonblocking?) sendmsg(). just fall back */
109 TRACE(("sendmsg tcp_fastopen failed, falling back. %s", strerror(errno))); 111 TRACE(("sendmsg tcp_fastopen failed, falling back. %s", strerror(errno)));
110 /* No kernel MSG_FASTOPEN support. Fall back below */ 112 /* No kernel MSG_FASTOPEN support. Fall back below */
111 fastopen = 0; 113 fastopen = 0;
122 res = connect(c->sock, r->ai_addr, r->ai_addrlen); 124 res = connect(c->sock, r->ai_addr, r->ai_addrlen);
123 } 125 }
124 126
125 if (res < 0 && errno != EINPROGRESS) { 127 if (res < 0 && errno != EINPROGRESS) {
126 /* failure */ 128 /* failure */
129 m_free(c->errstring);
130 c->errstring = m_strdup(strerror(errno));
127 close(c->sock); 131 close(c->sock);
128 c->sock = -1; 132 c->sock = -1;
129 continue; 133 continue;
130 } else { 134 } else {
131 /* new connection was successful, wait for it to complete */ 135 /* new connection was successful, wait for it to complete */