接前一篇文章:ESP32-C3在MQTT访问时出现“transport_base: Poll timeout or error”问题的分析(3)
上两回分别解析了引发问题打印的ssl_write函数的赋值流程和调用流程,本回回归到ssl_write函数本身,聚焦于此函数本身的代码实现细节。为了便于理解和回顾,再次贴出ssl_write函数源码,在components\components\tcp_transport\transport_ssl.c中,如下:
static int ssl_write(esp_transport_handle_t t, const char *buffer, int len, int timeout_ms)
{
int poll;
transport_esp_tls_t *ssl = ssl_get_context_data(t);
if ((poll = esp_transport_poll_write(t, timeout_ms)) <= 0) {
ESP_LOGW(TAG, "Poll timeout or error, errno=%s, fd=%d, timeout_ms=%d", strerror(errno), ssl->sockfd, timeout_ms);
return poll;
}
int ret = esp_tls_conn_write(ssl->tls, (const unsigned char *) bu