}
/*
- * Determines the number of bytes available still to be read, and whether a FIN
- * has yet to be read.
+ * Determines the number of bytes available still to be read, and (if
+ * include_fin is 1) whether a FIN or reset has yet to be read.
*/
-static ossl_inline ossl_unused int ossl_quic_stream_recv_pending(const QUIC_STREAM *s)
+static ossl_inline ossl_unused int ossl_quic_stream_recv_pending(const QUIC_STREAM *s,
+ int include_fin)
{
size_t avail;
int fin = 0;
if (!ossl_quic_rstream_available(s->rstream, &avail, &fin))
avail = 0;
- if (avail == 0 && fin)
+ if (avail == 0 && include_fin && fin)
avail = 1;
return avail;
case QUIC_RSTREAM_STATE_RESET_RECVD:
- return 1;
+ return include_fin;
case QUIC_RSTREAM_STATE_DATA_READ:
case QUIC_RSTREAM_STATE_RESET_READ:
quic_post_write(xso, *written > 0, *written == len, flags,
qctx_should_autotick(ctx));
+
+ if (*written == 0)
+ /* SSL_write_ex returns 0 if it didn't read anything. */
+ return QUIC_RAISE_NORMAL_ERROR(ctx, SSL_ERROR_WANT_READ);
+
return 1;
}
}
if (check_channel)
- avail = ossl_quic_stream_recv_pending(ctx.xso->stream)
+ avail = ossl_quic_stream_recv_pending(ctx.xso->stream,
+ /*include_fin=*/1)
|| ossl_quic_channel_has_pending(ctx.qc->ch)
|| ossl_quic_channel_is_term_any(ctx.qc->ch);
else
- avail = ossl_quic_stream_recv_pending(ctx.xso->stream);
+ avail = ossl_quic_stream_recv_pending(ctx.xso->stream,
+ /*include_fin=*/0);
out:
quic_unlock(ctx.qc);