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 concurrency issue on task_running value #401

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/transport/multicast/lease.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,14 @@ void *_zp_multicast_lease_task(void *ztm_arg) {
int8_t _zp_multicast_start_lease_task(_z_transport_multicast_t *ztm, z_task_attr_t *attr, z_task_t *task) {
// Init memory
(void)memset(task, 0, sizeof(z_task_t));
ztm->_lease_task_running = true; // Init before z_task_init for concurrency issue
// Init task
if (z_task_init(task, attr, _zp_multicast_lease_task, ztm) != _Z_RES_OK) {
ztm->_lease_task_running = false;
return _Z_ERR_SYSTEM_TASK_FAILED;
}
// Attach task
ztm->_lease_task = task;
ztm->_lease_task_running = true;
return _Z_RES_OK;
}

Expand Down
3 changes: 2 additions & 1 deletion src/transport/multicast/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,14 @@ void *_zp_multicast_read_task(void *ztm_arg) {
int8_t _zp_multicast_start_read_task(_z_transport_t *zt, z_task_attr_t *attr, z_task_t *task) {
// Init memory
(void)memset(task, 0, sizeof(z_task_t));
zt->_transport._multicast._read_task_running = true; // Init before z_task_init for concurrency issue
// Init task
if (z_task_init(task, attr, _zp_multicast_read_task, &zt->_transport._multicast) != _Z_RES_OK) {
zt->_transport._multicast._read_task_running = false;
return _Z_ERR_SYSTEM_TASK_FAILED;
}
// Attach task
zt->_transport._multicast._read_task = task;
zt->_transport._multicast._read_task_running = true;
return _Z_RES_OK;
}

Expand Down
3 changes: 2 additions & 1 deletion src/transport/raweth/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,14 @@ void *_zp_raweth_read_task(void *ztm_arg) {
int8_t _zp_raweth_start_read_task(_z_transport_t *zt, z_task_attr_t *attr, z_task_t *task) {
// Init memory
(void)memset(task, 0, sizeof(z_task_t));
zt->_transport._raweth._read_task_running = true; // Init before z_task_init for concurrency issue
// Init task
if (z_task_init(task, attr, _zp_raweth_read_task, &zt->_transport._raweth) != _Z_RES_OK) {
zt->_transport._raweth._read_task_running = false;
return _Z_ERR_SYSTEM_TASK_FAILED;
}
// Attach task
zt->_transport._raweth._read_task = task;
zt->_transport._raweth._read_task_running = true;
return _Z_RES_OK;
}

Expand Down
3 changes: 2 additions & 1 deletion src/transport/unicast/lease.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,14 @@ void *_zp_unicast_lease_task(void *ztu_arg) {
int8_t _zp_unicast_start_lease_task(_z_transport_t *zt, z_task_attr_t *attr, z_task_t *task) {
// Init memory
(void)memset(task, 0, sizeof(z_task_t));
zt->_transport._unicast._lease_task_running = true; // Init before z_task_init for concurrency issue
// Init task
if (z_task_init(task, attr, _zp_unicast_lease_task, &zt->_transport._unicast) != _Z_RES_OK) {
zt->_transport._unicast._lease_task_running = false;
return _Z_ERR_SYSTEM_TASK_FAILED;
}
// Attach task
zt->_transport._unicast._lease_task = task;
zt->_transport._unicast._lease_task_running = true;
return _Z_RES_OK;
}

Expand Down
3 changes: 2 additions & 1 deletion src/transport/unicast/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,14 @@ void *_zp_unicast_read_task(void *ztu_arg) {
int8_t _zp_unicast_start_read_task(_z_transport_t *zt, z_task_attr_t *attr, z_task_t *task) {
// Init memory
(void)memset(task, 0, sizeof(z_task_t));
zt->_transport._unicast._read_task_running = true; // Init before z_task_init for concurrency issue
// Init task
if (z_task_init(task, attr, _zp_unicast_read_task, &zt->_transport._unicast) != _Z_RES_OK) {
zt->_transport._unicast._read_task_running = false;
return _Z_ERR_SYSTEM_TASK_FAILED;
}
// Attach task
zt->_transport._unicast._read_task = task;
zt->_transport._unicast._read_task_running = true;
return _Z_RES_OK;
}

Expand Down
Loading