LWS_VISIBLE int lws_ssl_pending(struct lws *wsi) { if (!wsi->ssl) return 0; #if defined(LWS_USE_POLARSSL) return ssl_get_bytes_avail(wsi->ssl) > 0; #else #if defined(LWS_USE_MBEDTLS) return ssl_get_bytes_avail(wsi->ssl) > 0;; #else return SSL_pending(wsi->ssl); #endif #endif }
static bool Curl_polarssl_data_pending(const struct connectdata *conn, int sockindex) { const struct ssl_connect_data *connssl = &conn->ssl[sockindex]; return ssl_get_bytes_avail(&BACKEND->ssl) != 0; }
/* See if data from SSL connection is read to be read */ int ssl_pending(ssl_context *ssl) { return ssl_get_bytes_avail(ssl); }
LWS_VISIBLE int lws_ssl_capable_read(struct lws *wsi, unsigned char *buf, int len) { struct lws_context *context = wsi->context; struct lws_context_per_thread *pt = &context->pt[(int)wsi->tsi]; int n = 0; if (!wsi->ssl) return lws_ssl_capable_read_no_ssl(wsi, buf, len); #if defined(LWS_USE_POLARSSL) #else #if defined(LWS_USE_MBEDTLS) #else n = SSL_read(wsi->ssl, buf, len); #endif #endif /* manpage: returning 0 means connection shut down */ if (!n) return LWS_SSL_CAPABLE_ERROR; if (n < 0) { n = lws_ssl_get_error(wsi, n); if (n == SSL_ERROR_WANT_READ || n == SSL_ERROR_WANT_WRITE) return LWS_SSL_CAPABLE_MORE_SERVICE; return LWS_SSL_CAPABLE_ERROR; } if (wsi->vhost) wsi->vhost->rx += n; lws_restart_ws_ping_pong_timer(wsi); /* * if it was our buffer that limited what we read, * check if SSL has additional data pending inside SSL buffers. * * Because these won't signal at the network layer with POLLIN * and if we don't realize, this data will sit there forever */ if (n != len) goto bail; if (!wsi->ssl) goto bail; #if defined(LWS_USE_POLARSSL) if (ssl_get_bytes_avail(wsi->ssl) <= 0) goto bail; #else #if defined(LWS_USE_MBEDTLS) #else if (!SSL_pending(wsi->ssl)) goto bail; #endif #endif if (wsi->pending_read_list_next) return n; if (wsi->pending_read_list_prev) return n; if (pt->pending_read_list == wsi) return n; /* add us to the linked list of guys with pending ssl */ if (pt->pending_read_list) pt->pending_read_list->pending_read_list_prev = wsi; wsi->pending_read_list_next = pt->pending_read_list; wsi->pending_read_list_prev = NULL; pt->pending_read_list = wsi; return n; bail: lws_ssl_remove_wsi_from_buffered_list(wsi); return n; }