| 
														
															@@ -3492,17 +3492,19 @@ handle_control_extendcircuit(control_connection_t *conn, uint32_t len, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   smartlist_free(args); 
														 | 
														
														 | 
														
															   smartlist_free(args); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															   nodes = smartlist_new(); 
														 | 
														
														 | 
														
															   nodes = smartlist_new(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  int first_node = zero_circ; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   SMARTLIST_FOREACH_BEGIN(router_nicknames, const char *, n) { 
														 | 
														
														 | 
														
															   SMARTLIST_FOREACH_BEGIN(router_nicknames, const char *, n) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     const node_t *node = node_get_by_nickname(n, 0); 
														 | 
														
														 | 
														
															     const node_t *node = node_get_by_nickname(n, 0); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     if (!node) { 
														 | 
														
														 | 
														
															     if (!node) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       connection_printf_to_buf(conn, "552 No such router \"%s\"\r\n", n); 
														 | 
														
														 | 
														
															       connection_printf_to_buf(conn, "552 No such router \"%s\"\r\n", n); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       goto done; 
														 | 
														
														 | 
														
															       goto done; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     } 
														 | 
														
														 | 
														
															     } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    if (!node_has_any_descriptor(node)) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    if (!node_has_preferred_descriptor(node, first_node)) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       connection_printf_to_buf(conn, "552 No descriptor for \"%s\"\r\n", n); 
														 | 
														
														 | 
														
															       connection_printf_to_buf(conn, "552 No descriptor for \"%s\"\r\n", n); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       goto done; 
														 | 
														
														 | 
														
															       goto done; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     } 
														 | 
														
														 | 
														
															     } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     smartlist_add(nodes, (void*)node); 
														 | 
														
														 | 
														
															     smartlist_add(nodes, (void*)node); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    first_node = 0; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   } SMARTLIST_FOREACH_END(n); 
														 | 
														
														 | 
														
															   } SMARTLIST_FOREACH_END(n); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   if (!smartlist_len(nodes)) { 
														 | 
														
														 | 
														
															   if (!smartlist_len(nodes)) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     connection_write_str_to_buf("512 No router names provided\r\n", conn); 
														 | 
														
														 | 
														
															     connection_write_str_to_buf("512 No router names provided\r\n", conn); 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -3515,14 +3517,15 @@ handle_control_extendcircuit(control_connection_t *conn, uint32_t len, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   } 
														 | 
														
														 | 
														
															   } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															   /* now circ refers to something that is ready to be extended */ 
														 | 
														
														 | 
														
															   /* now circ refers to something that is ready to be extended */ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  int first_node = zero_circ; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  first_node = zero_circ; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   SMARTLIST_FOREACH(nodes, const node_t *, node, 
														 | 
														
														 | 
														
															   SMARTLIST_FOREACH(nodes, const node_t *, node, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   { 
														 | 
														
														 | 
														
															   { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     extend_info_t *info = extend_info_from_node(node, first_node); 
														 | 
														
														 | 
														
															     extend_info_t *info = extend_info_from_node(node, first_node); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     if (!info) { 
														 | 
														
														 | 
														
															     if (!info) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       tor_assert_nonfatal(first_node); 
														 | 
														
														 | 
														
															       tor_assert_nonfatal(first_node); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       log_warn(LD_CONTROL, 
														 | 
														
														 | 
														
															       log_warn(LD_CONTROL, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-               "controller tried to connect to a node that doesn't have any " 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+               "controller tried to connect to a node that lacks a suitable " 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+               "descriptor, or which doesn't have any " 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                "addresses that are allowed by the firewall configuration; " 
														 | 
														
														 | 
														
															                "addresses that are allowed by the firewall configuration; " 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                "circuit marked for closing."); 
														 | 
														
														 | 
														
															                "circuit marked for closing."); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       circuit_mark_for_close(TO_CIRCUIT(circ), -END_CIRC_REASON_CONNECTFAILED); 
														 | 
														
														 | 
														
															       circuit_mark_for_close(TO_CIRCUIT(circ), -END_CIRC_REASON_CONNECTFAILED); 
														 |