Skip to content

Commit

Permalink
fix: concurrency issue on task_running init value (#401)
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-roland authored Apr 10, 2024
1 parent d0b07f8 commit c5008cb
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
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

0 comments on commit c5008cb

Please sign in to comment.