Stabilize concurrent SSH and WebSocket transports
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include "serial_service.h"
|
||||
|
||||
#define SESSION_BROKER_RX_CHUNK_SIZE 256U
|
||||
#define SESSION_BROKER_ACTIVE_BURST_BYTES (8U * SESSION_BROKER_RX_CHUNK_SIZE)
|
||||
#define SESSION_BROKER_TASK_STACK_SIZE 4096U
|
||||
#define SESSION_BROKER_TASK_PRIORITY 9U
|
||||
#define SESSION_BROKER_IDLE_POLL_MS 5U
|
||||
@@ -160,6 +161,7 @@ static void broker_task(void *context)
|
||||
{
|
||||
(void)context;
|
||||
uint8_t data[SESSION_BROKER_RX_CHUNK_SIZE];
|
||||
size_t active_burst_bytes = 0U;
|
||||
|
||||
for (;;) {
|
||||
/*
|
||||
@@ -175,7 +177,20 @@ static void broker_task(void *context)
|
||||
xSemaphoreGive(s_mutex);
|
||||
|
||||
if (received == 0U) {
|
||||
active_burst_bytes = 0U;
|
||||
vTaskDelay(milliseconds_to_ticks(SESSION_BROKER_IDLE_POLL_MS));
|
||||
} else {
|
||||
active_burst_bytes += received;
|
||||
if (active_burst_bytes >= SESSION_BROKER_ACTIVE_BURST_BYTES) {
|
||||
active_burst_bytes = 0U;
|
||||
/*
|
||||
* A continuously readable UART must not make this priority-9
|
||||
* task permanently runnable. One tick after each bounded burst
|
||||
* preserves 1 Mbaud headroom while allowing idle and transports
|
||||
* to run on a loaded dual-core system.
|
||||
*/
|
||||
vTaskDelay(1U);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "lwip/inet.h"
|
||||
#include "lwip/sockets.h"
|
||||
#include "lwip/tcp.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "secure_random.h"
|
||||
#include "serial_service.h"
|
||||
#include "ssh_security.h"
|
||||
@@ -26,6 +27,14 @@
|
||||
#include <wolfssl/wolfcrypt/random.h>
|
||||
#include <wolfssh/ssh.h>
|
||||
|
||||
#if defined(CONFIG_MBEDTLS_HARDWARE_AES) && CONFIG_MBEDTLS_HARDWARE_AES
|
||||
#error "Concurrent mbedTLS/wolfSSH operation requires mbedTLS software AES"
|
||||
#endif
|
||||
#if !defined(NO_WOLFSSL_ESP32_CRYPT_AES) || \
|
||||
!defined(NO_WOLFSSL_ESP32_CRYPT_HASH)
|
||||
#error "wolfSSH AES/SHA must not use independently locked ESP32 crypto hardware"
|
||||
#endif
|
||||
|
||||
#define SSH_TRANSPORT_TASK_STACK_SIZE 20480U
|
||||
#define SSH_TRANSPORT_TASK_PRIORITY 5U
|
||||
#define SSH_TRANSPORT_TASK_CORE 1
|
||||
|
||||
@@ -58,7 +58,7 @@ static bool s_line_coding_pending;
|
||||
static usb_cdc_transport_counters_t s_counters;
|
||||
|
||||
static const char s_language_descriptor[] = {0x09, 0x04};
|
||||
static const char s_manufacturer[] = "ESP32 Serial Tools";
|
||||
static const char s_manufacturer[] = "Commander1024";
|
||||
/* esp_tinyusb's default UTF-16 conversion accepts at most 31 characters. */
|
||||
static const char s_product[] = "ESP32 Serial Swiss Army Knife";
|
||||
static char s_serial_number[13];
|
||||
|
||||
@@ -27,7 +27,8 @@
|
||||
#define WEB_SERIAL_ORIGIN_CAPACITY (sizeof("https://") + WEB_SERIAL_HOST_CAPACITY)
|
||||
#define WEB_SERIAL_TICKET_RESPONSE_CAPACITY 96U
|
||||
#define WEB_SERIAL_TASK_STACK_SIZE 6144U
|
||||
#define WEB_SERIAL_TASK_PRIORITY 7U
|
||||
#define WEB_SERIAL_TASK_PRIORITY 4U
|
||||
#define WEB_SERIAL_ACTIVE_BURST_LOOPS 8U
|
||||
#define WEB_SERIAL_POLL_MS 5U
|
||||
#define WEB_SERIAL_DETACH_TIMEOUT_US 1000000LL
|
||||
|
||||
@@ -1214,6 +1215,8 @@ static void process_active_output(web_serial_slot_t *slot)
|
||||
static void transport_task(void *context)
|
||||
{
|
||||
(void)context;
|
||||
size_t active_burst_loops = 0U;
|
||||
|
||||
for (;;) {
|
||||
for (size_t index = 0U; index < WEB_SERIAL_TRANSPORT_MAX_SESSIONS;
|
||||
++index) {
|
||||
@@ -1222,8 +1225,20 @@ static void transport_task(void *context)
|
||||
process_broker_disconnect(slot);
|
||||
process_active_output(slot);
|
||||
}
|
||||
(void)ulTaskNotifyTake(pdTRUE,
|
||||
milliseconds_to_ticks(WEB_SERIAL_POLL_MS));
|
||||
|
||||
uint32_t notifications = ulTaskNotifyTake(
|
||||
pdTRUE, milliseconds_to_ticks(WEB_SERIAL_POLL_MS));
|
||||
if (notifications == 0U) {
|
||||
active_burst_loops = 0U;
|
||||
} else if (++active_burst_loops >= WEB_SERIAL_ACTIVE_BURST_LOOPS) {
|
||||
active_burst_loops = 0U;
|
||||
/*
|
||||
* Send completion normally wakes this task immediately. Bound that
|
||||
* producer/HTTPD hand-off so sustained serial output cannot keep an
|
||||
* application task runnable forever and starve an idle watchdog.
|
||||
*/
|
||||
vTaskDelay(1U);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user