It looks like selecting preferred_addr does not wait for handshake confirmation
@@ -6017,8 +6017,6 @@ static int conn_select_preferred_addr(ngtcp2_conn *conn) {
* User-defined callback function failed.
*/
static int conn_recv_handshake_done(ngtcp2_conn *conn) {
- int rv;
-
if (conn->server) {
return NGTCP2_ERR_PROTO;
}
@@ -6031,13 +6029,6 @@ static int conn_recv_handshake_done(ngtcp2_conn *conn) {
conn_discard_handshake_state(conn);
- if (conn->remote.transport_params.preferred_address_present) {
- rv = conn_select_preferred_addr(conn);
- if (rv != 0) {
- return rv;
- }
- }
-
/* TODO Call handshake_done callback */
return 0;
@@ -7328,6 +7319,13 @@ static ngtcp2_ssize conn_write_handshake(ngtcp2_conn *conn, uint8_t *dest,
return (ngtcp2_ssize)rv;
}
+ if (conn->remote.transport_params.preferred_address_present) {
+ rv = conn_select_preferred_addr(conn);
+ if (rv != 0) {
+ return rv;
+ }
+ }
+
return res;
case NGTCP2_CS_SERVER_INITIAL:
nwrite = conn_write_server_handshake(conn, dest, destlen, ts);
