Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix WiFiGeneric event handler #3412

Merged
merged 1 commit into from
Nov 11, 2019
Merged

Fix WiFiGeneric event handler #3412

merged 1 commit into from
Nov 11, 2019

Conversation

mikhail-khalizev
Copy link
Contributor

Hi.

Summary

Currently _network_event_cb pass pointer to system_event_t into _network_event_queue, instead of value.
I think this wrong. And this pull request fix that.

Description

Method esp_event_loop_task that calls _network_event_cb stores system_event_t in stack:

static void esp_event_loop_task(void *pvParameters)
{
    while (1) {
        system_event_t evt;
        if (xQueueReceive(s_event_queue, &evt, portMAX_DELAY) == pdPASS) {
            esp_err_t ret = esp_event_process_default(&evt);
            if (ret != ESP_OK) {
                ESP_LOGE(TAG, "default event handler failed!");
            }
            ret = esp_event_post_to_user(&evt);
            if (ret != ESP_OK) {
                ESP_LOGE(TAG, "post event to user fail!");
            }
        }
    }
}

So when _network_event_cb sent pointer in _network_event_queue it stores pointer to stack in queue. And if several events occurs it send the same value of pointer to _network_event_queue. It is not that we want.

And more, when _network_event_task reads this pointer, value of system_event_t may be corrupt, because in this time in parallel task method esp_event_loop_task calls xQueueReceive that replacing system_event_t.

@me-no-dev me-no-dev merged commit ec63d09 into espressif:master Nov 11, 2019
@me-no-dev
Copy link
Member

yup :) agreed!

@mikhail-khalizev mikhail-khalizev deleted the feature/fix-wifi-event-handler branch November 11, 2019 13:43
everslick added a commit to everslick/Arduino-ESP32-1.0.0 that referenced this pull request Nov 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants