mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
transport/pthread: fix some issues for component
1. transport_ssl: fix transport ssl blocking 2. pthread: fix the priority inheritance
This commit is contained in:
parent
b94eec73fa
commit
7669600253
@ -156,17 +156,22 @@ static const char *HTTP_METHOD_MAPPING[] = {
|
||||
static void *http_malloc(size_t size)
|
||||
{
|
||||
void *data = NULL;
|
||||
#if CONFIG_SPIRAM_USE_MALLOC
|
||||
data = heap_caps_malloc(size, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
|
||||
#else
|
||||
data = malloc(size);
|
||||
#endif
|
||||
return data;
|
||||
}
|
||||
|
||||
static void *http_calloc(size_t nmemb, size_t size)
|
||||
{
|
||||
void *data = NULL;
|
||||
data = heap_caps_malloc(nmemb * size, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
|
||||
if (data) {
|
||||
memset(data, 0, nmemb * size);
|
||||
}
|
||||
#if CONFIG_SPIRAM_USE_MALLOC
|
||||
data = heap_caps_calloc(nmemb, size, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
|
||||
#else
|
||||
data = calloc(nmemb, size);
|
||||
#endif
|
||||
return data;
|
||||
}
|
||||
|
||||
|
@ -591,6 +591,14 @@ int pthread_mutex_destroy(pthread_mutex_t *mutex)
|
||||
return EBUSY;
|
||||
}
|
||||
|
||||
if (mux->type == PTHREAD_MUTEX_RECURSIVE) {
|
||||
res = xSemaphoreGiveRecursive(mux->sem);
|
||||
} else {
|
||||
res = xSemaphoreGive(mux->sem);
|
||||
}
|
||||
if (res != pdTRUE) {
|
||||
assert(false && "Failed to release mutex!");
|
||||
}
|
||||
vSemaphoreDelete(mux->sem);
|
||||
free(mux);
|
||||
|
||||
|
@ -80,12 +80,17 @@ static int ssl_connect(esp_transport_handle_t t, const char *host, int port, int
|
||||
static int ssl_poll_read(esp_transport_handle_t t, int timeout_ms)
|
||||
{
|
||||
transport_ssl_t *ssl = esp_transport_get_context_data(t);
|
||||
int remain = 0;
|
||||
fd_set readset;
|
||||
FD_ZERO(&readset);
|
||||
FD_SET(ssl->tls->sockfd, &readset);
|
||||
struct timeval timeout;
|
||||
esp_transport_utils_ms_to_timeval(timeout_ms, &timeout);
|
||||
|
||||
if ((remain = esp_tls_get_bytes_avail(ssl->tls)) > 0) {
|
||||
ESP_LOGD(TAG, "remain data in cache, need to read again");
|
||||
return remain;
|
||||
}
|
||||
return select(ssl->tls->sockfd + 1, &readset, NULL, NULL, &timeout);
|
||||
}
|
||||
|
||||
@ -121,10 +126,8 @@ static int ssl_read(esp_transport_handle_t t, char *buffer, int len, int timeout
|
||||
int poll, ret;
|
||||
transport_ssl_t *ssl = esp_transport_get_context_data(t);
|
||||
|
||||
if (esp_tls_get_bytes_avail(ssl->tls) <= 0) {
|
||||
if ((poll = esp_transport_poll_read(t, timeout_ms)) <= 0) {
|
||||
return poll;
|
||||
}
|
||||
if ((poll = esp_transport_poll_read(t, timeout_ms)) <= 0) {
|
||||
return poll;
|
||||
}
|
||||
ret = esp_tls_conn_read(ssl->tls, (unsigned char *)buffer, len);
|
||||
if (ret < 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user