Skip to content

Commit

Permalink
QUIC: Fix multistream test on macOS
Browse files Browse the repository at this point in the history
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from #21135)
  • Loading branch information
hlandau authored and paulidale committed Jul 16, 2023
1 parent 8aa6a43 commit 9ff3a99
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 1 deletion.
3 changes: 3 additions & 0 deletions include/internal/quic_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,9 @@ uint64_t ossl_quic_channel_get_rx_key_epoch(QUIC_CHANNEL *ch);
int ossl_quic_channel_trigger_txku(QUIC_CHANNEL *ch);
int ossl_quic_channel_has_pending(const QUIC_CHANNEL *ch);

/* Force transmission of an ACK-eliciting packet. */
int ossl_quic_channel_ping(QUIC_CHANNEL *ch);

# endif

#endif
3 changes: 3 additions & 0 deletions include/internal/quic_tserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ OSSL_TIME ossl_quic_tserver_get_deadline(QUIC_TSERVER *srv);
*/
int ossl_quic_tserver_shutdown(QUIC_TSERVER *srv);

/* Force generation of an ACK-eliciting packet. */
int ossl_quic_tserver_ping(QUIC_TSERVER *srv);

# endif

#endif
9 changes: 9 additions & 0 deletions ssl/quic/quic_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -3117,3 +3117,12 @@ int ossl_quic_channel_trigger_txku(QUIC_CHANNEL *ch)
ch_trigger_txku(ch);
return 1;
}

int ossl_quic_channel_ping(QUIC_CHANNEL *ch)
{
int pn_space = ossl_quic_enc_level_to_pn_space(ch->tx_enc_level);

ossl_quic_tx_packetiser_schedule_ack_eliciting(ch->txp, pn_space);

return 1;
}
12 changes: 12 additions & 0 deletions ssl/quic/quic_tserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,3 +489,15 @@ int ossl_quic_tserver_shutdown(QUIC_TSERVER *srv)

return ossl_quic_channel_is_terminated(srv->ch);
}

int ossl_quic_tserver_ping(QUIC_TSERVER *srv)
{
if (ossl_quic_channel_is_terminated(srv->ch))
return 0;

if (!ossl_quic_channel_ping(srv->ch))
return 0;

ossl_quic_reactor_tick(ossl_quic_channel_get_reactor(srv->ch), 0);
return 1;
}
9 changes: 8 additions & 1 deletion test/quic_multistream_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -1286,8 +1286,10 @@ static int run_script_worker(struct helper *h, const struct script_op *script,
int expect_remote = (op->arg1 & EXPECT_CONN_CLOSE_REMOTE) != 0;
uint64_t error_code = op->arg2;

if (!ossl_quic_tserver_is_term_any(h->s))
if (!ossl_quic_tserver_is_term_any(h->s)) {
ossl_quic_tserver_ping(h->s);
SPIN_AGAIN();
}

if (!TEST_ptr(tc = ossl_quic_tserver_get_terminate_cause(h->s)))
goto out;
Expand Down Expand Up @@ -1721,11 +1723,16 @@ static const struct script_op script_5[] = {

OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE)
OP_C_NEW_STREAM_BIDI (a, C_BIDI_ID(0))
OP_C_NEW_STREAM_BIDI (b, C_BIDI_ID(1))

OP_C_WRITE (a, "apple", 5)
OP_C_STREAM_RESET (a, 42)

OP_C_WRITE (b, "strawberry", 10)

OP_S_BIND_STREAM_ID (a, C_BIDI_ID(0))
OP_S_BIND_STREAM_ID (b, C_BIDI_ID(1))
OP_S_READ_EXPECT (b, "strawberry", 10)
/* Reset disrupts read of already sent data */
OP_S_READ_FAIL (a)
OP_CHECK (check_stream_reset, C_BIDI_ID(0))
Expand Down

0 comments on commit 9ff3a99

Please sign in to comment.