}
}
+static void
+tls_read_stop(isc_nmsocket_t *sock);
+
static void
tls_failed_read_cb(isc_nmsocket_t *sock, const isc_result_t result);
tls_call_connect_cb(sock, handle, result);
isc__nmsocket_clearcb(sock);
isc_nmhandle_detach(&handle);
- } else if (sock->recv_cb != NULL && sock->statichandle != NULL) {
+ } else if (sock->recv_cb != NULL && sock->statichandle != NULL &&
+ (sock->recv_read || result == ISC_R_TIMEDOUT))
+ {
+ sock->recv_read = false;
sock->recv_cb(sock->statichandle, result, NULL,
sock->recv_cbarg);
if (result == ISC_R_TIMEDOUT &&
if (!inactive(sock) && sock->tlsstream.state == TLS_IO) {
tls_do_bio(sock, NULL, NULL, true);
- } else if (sock->reading) {
- sock->reading = false;
+ } else if (sock->recv_read) {
+ tls_read_stop(sock);
tls_failed_read_cb(sock, result);
}
}
INSIST(sock->statichandle == NULL);
isc__nmsocket_log_tls_session_reuse(sock, sock->tlsstream.tls);
tlshandle = isc__nmhandle_get(sock, &sock->peer, &sock->iface);
+ tls_read_stop(sock);
if (sock->tlsstream.server) {
if (isc__nmsocket_closing(sock->listener)) {
result = ISC_R_CANCELED;
REQUIRE(sock->tid == isc_tid());
was_reading = sock->reading;
- /* We will resume read if TLS layer wants us to */
- if (sock->reading && sock->outerhandle) {
- REQUIRE(VALID_NMHANDLE(sock->outerhandle));
- isc_nm_read_stop(sock->outerhandle);
- }
/*
* Clear the TLS error queue so that SSL_get_error() and SSL I/O
sock->outerhandle == NULL)
{
return;
+ } else if (sock->reading == false &&
+ sock->tlsstream.state > TLS_HANDSHAKE)
+ {
+ /* We need to read data when doing handshake even if
+ * 'sock->reading == false' */
+ return;
}
INSIST(VALID_NMHANDLE(sock->outerhandle));
- sock->reading = true;
isc_nm_read(sock->outerhandle, tls_readcb, sock);
return;
default:
sock->recv_cb = cb;
sock->recv_cbarg = cbarg;
+ sock->recv_read = true;
+ sock->reading = true;
- if (sock->reading) {
- return;
- }
+ async_tls_do_bio(sock);
+}
- tls_do_bio(sock, NULL, NULL, false);
+static void
+tls_read_stop(isc_nmsocket_t *sock) {
+ sock->reading = false;
+
+ if (sock->outerhandle != NULL) {
+ isc_nm_read_stop(sock->outerhandle);
+ }
}
void
REQUIRE(VALID_NMHANDLE(handle));
REQUIRE(VALID_NMSOCK(handle->sock));
- isc_nmsocket_t *sock = handle->sock;
-
- sock->reading = false;
-
- if (sock->outerhandle != NULL) {
- isc_nm_read_stop(sock->outerhandle);
- }
+ tls_read_stop(handle->sock);
}
static void