aboutsummaryrefslogtreecommitdiffstats
path: root/ssl/d1_lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'ssl/d1_lib.c')
-rw-r--r--ssl/d1_lib.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/ssl/d1_lib.c b/ssl/d1_lib.c
index c4b01779c93..c4a3d32bcd8 100644
--- a/ssl/d1_lib.c
+++ b/ssl/d1_lib.c
@@ -3385,7 +3385,17 @@ int ossl_dtls_conn_poll_events(SSL *s, uint64_t events, int do_tick,
SSL_handle_events(s);
if ((events & SSL_POLL_EVENT_R) != 0) {
- if (SSL_has_pending(s) || SSL_pending(s) > 0) {
+ /*
+ * Application data buffered during a handshake cannot be read until
+ * the handshake finishes. Until then, reporting it would make
+ * SSL_poll() return immediately while SSL_read() keeps failing with
+ * SSL_ERROR_WANT_READ, so wait for the datagrams that complete the
+ * handshake instead.
+ */
+ if (RECORD_LAYER_processed_read_pending(&sc->rlayer)
+ || RECORD_LAYER_read_pending(&sc->rlayer)
+ || (SSL_is_init_finished(s)
+ && DTLS_RECORD_LAYER_buffered_app_data_pending(&sc->rlayer))) {
result |= SSL_POLL_EVENT_R;
} else if (sc->d1->rx != NULL) {
/* Listener-based connection: check URXE queue */