__owur int ossl_quic_has_pending(const SSL *s);
__owur int ossl_quic_handle_events(SSL *s);
-__owur int ossl_quic_get_event_timeout(SSL *s, struct timeval *tv);
+__owur int ossl_quic_get_event_timeout(SSL *s, struct timeval *tv,
+ int *is_infinite);
OSSL_TIME ossl_quic_get_event_deadline(SSL *s);
__owur int ossl_quic_get_rpoll_descriptor(SSL *s, BIO_POLL_DESCRIPTOR *d);
__owur int ossl_quic_get_wpoll_descriptor(SSL *s, BIO_POLL_DESCRIPTOR *d);
/* QUIC support */
int SSL_handle_events(SSL *s);
-__owur int SSL_get_event_timeout(SSL *s, struct timeval *tv);
+__owur int SSL_get_event_timeout(SSL *s, struct timeval *tv, int *is_infinite);
__owur int SSL_get_rpoll_descriptor(SSL *s, BIO_POLL_DESCRIPTOR *desc);
__owur int SSL_get_wpoll_descriptor(SSL *s, BIO_POLL_DESCRIPTOR *desc);
__owur int SSL_net_read_desired(SSL *s);
/*
* SSL_get_event_timeout. Get the time in milliseconds until the SSL object
* should be ticked by the application by calling SSL_handle_events(). tv is set
- * to 0 if the object should be ticked immediately and tv->tv_sec is set to -1
- * if no timeout is currently active.
+ * to 0 if the object should be ticked immediately. If no timeout is currently
+ * active, *is_infinite is set to 1 and the value of *tv is undefined.
*/
QUIC_TAKES_LOCK
-int ossl_quic_get_event_timeout(SSL *s, struct timeval *tv)
+int ossl_quic_get_event_timeout(SSL *s, struct timeval *tv, int *is_infinite)
{
QCTX ctx;
OSSL_TIME deadline = ossl_time_infinite();
= ossl_quic_reactor_get_tick_deadline(ossl_quic_channel_get_reactor(ctx.qc->ch));
if (ossl_time_is_infinite(deadline)) {
- tv->tv_sec = -1;
+ *is_infinite = 1;
+
+ /*
+ * Robustness against faulty applications that don't check *is_infinite;
+ * harmless long timeout.
+ */
+ tv->tv_sec = 1000000;
tv->tv_usec = 0;
+
quic_unlock(ctx.qc);
return 1;
}
*tv = ossl_time_to_timeval(ossl_time_subtract(deadline, ossl_time_now()));
+ *is_infinite = 0;
quic_unlock(ctx.qc);
return 1;
}
return 1;
}
-int SSL_get_event_timeout(SSL *s, struct timeval *tv)
+int SSL_get_event_timeout(SSL *s, struct timeval *tv, int *is_infinite)
{
SSL_CONNECTION *sc;
#ifndef OPENSSL_NO_QUIC
if (IS_QUIC(s))
- return ossl_quic_get_event_timeout(s, tv);
+ return ossl_quic_get_event_timeout(s, tv, is_infinite);
#endif
sc = SSL_CONNECTION_FROM_SSL_ONLY(s);
if (sc != NULL && SSL_CONNECTION_IS_DTLS(sc)
- && DTLSv1_get_timeout(s, tv))
+ && DTLSv1_get_timeout(s, tv)) {
+ *is_infinite = 0;
return 1;
+ }
- tv->tv_sec = -1;
+ tv->tv_sec = 1000000;
tv->tv_usec = 0;
+ *is_infinite = 1;
return 1;
}