Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix WiFiGeneric event handler #3411

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

Closed
wants to merge 1 commit into from
Closed

Fix WiFiGeneric event handler #3411

wants to merge 1 commit into from

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.

@mikhail-khalizev mikhail-khalizev changed the base branch from idf-release/v3.3 to master October 26, 2019 13:50
@mikhail-khalizev mikhail-khalizev changed the base branch from master to idf-release/v3.3 October 26, 2019 13:50
@mikhail-khalizev
Copy link
Contributor Author

Replaced by #3412

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.

1 participant