diff netio.c @ 1173:d734fe76b72f coverity

merge
author Matt Johnston <matt@ucc.asn.au>
date Mon, 23 Nov 2015 23:04:48 +0800
parents 57d09741d46d
children 750ec4ec4cbe 3b624ad2dc5e
line wrap: on
line diff
--- a/netio.c	Fri Aug 07 21:26:03 2015 +0800
+++ b/netio.c	Mon Nov 23 23:04:48 2015 +0800
@@ -174,28 +174,26 @@
 
 void set_connect_fds(fd_set *writefd) {
 	m_list_elem *iter;
-	TRACE(("enter handle_connect_fds"))
-	for (iter = ses.conn_pending.first; iter; iter = iter->next) {
+	TRACE(("enter set_connect_fds"))
+	iter = ses.conn_pending.first;
+	while (iter) {
+		m_list_elem *next_iter = iter->next;
 		struct dropbear_progress_connection *c = iter->item;
 		/* Set one going */
-		while (c->res_iter && c->sock < 0)
-		{
+		while (c->res_iter && c->sock < 0) {
 			connect_try_next(c);
 		}
 		if (c->sock >= 0) {
 			FD_SET(c->sock, writefd);
 		} else {
-			m_list_elem *remove_iter;
 			/* Final failure */
 			if (!c->errstring) {
 				c->errstring = m_strdup("unexpected failure");
 			}
 			c->cb(DROPBEAR_FAILURE, -1, c->cb_data, c->errstring);
-			/* Safely remove without invalidating iter */
-			remove_iter = iter;
-			iter = iter->prev;
-			remove_connect(c, remove_iter);
+			remove_connect(c, iter);
 		}
+		iter = next_iter;
 	}
 }