Mercurial > dropbear
comparison netio.c @ 1053:fd3712d1ff7f
Better failure handling
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sat, 28 Feb 2015 23:49:39 +0800 |
parents | c2a50c9f509e |
children | 23103e1e9548 |
comparison
equal
deleted
inserted
replaced
1051:359fba4b1a49 | 1053:fd3712d1ff7f |
---|---|
167 len = 100 + strlen(gai_strerror(err)); | 167 len = 100 + strlen(gai_strerror(err)); |
168 c->errstring = (char*)m_malloc(len); | 168 c->errstring = (char*)m_malloc(len); |
169 snprintf(c->errstring, len, "Error resolving '%s' port '%s'. %s", | 169 snprintf(c->errstring, len, "Error resolving '%s' port '%s'. %s", |
170 remotehost, remoteport, gai_strerror(err)); | 170 remotehost, remoteport, gai_strerror(err)); |
171 TRACE(("Error resolving: %s", gai_strerror(err))) | 171 TRACE(("Error resolving: %s", gai_strerror(err))) |
172 return NULL; | 172 } else { |
173 } | 173 c->res_iter = c->res; |
174 | 174 } |
175 c->res_iter = c->res; | |
176 | 175 |
177 return c; | 176 return c; |
178 } | 177 } |
179 | 178 |
180 void remove_connect_pending() { | 179 void remove_connect_pending() { |
218 for (iter = ses.conn_pending.first; iter; iter = iter->next) { | 217 for (iter = ses.conn_pending.first; iter; iter = iter->next) { |
219 int val; | 218 int val; |
220 socklen_t vallen = sizeof(val); | 219 socklen_t vallen = sizeof(val); |
221 struct dropbear_progress_connection *c = iter->item; | 220 struct dropbear_progress_connection *c = iter->item; |
222 | 221 |
223 if (!FD_ISSET(c->sock, writefd)) { | 222 if (c->sock < 0 || !FD_ISSET(c->sock, writefd)) { |
224 continue; | 223 continue; |
225 } | 224 } |
226 | 225 |
227 TRACE(("handling %s port %s socket %d", c->remotehost, c->remoteport, c->sock)); | 226 TRACE(("handling %s port %s socket %d", c->remotehost, c->remoteport, c->sock)); |
228 | 227 |