Skip to content
Snippets Groups Projects
Commit ed4090fe authored by rswindell's avatar rswindell
Browse files

Mutex-protect all of listRemoveNode (which includes listPopNode and

listShiftNode macros) for complete thread-safety.
parent e38dccbf
No related branches found
No related tags found
No related merge requests found
......@@ -629,17 +629,13 @@ link_list_t* DLLCALL listExtract(link_list_t* dest_list, const list_node_t* node
return(list);
}
void* DLLCALL listRemoveNode(link_list_t* list, list_node_t* node, BOOL free_data)
static void* list_remove_node(link_list_t* list, list_node_t* node, BOOL free_data)
{
void* data;
if(list==NULL)
return(NULL);
/* Should these lines be mutex protected? */
if(node==FIRST_NODE)
node=list->first;
if(node==LAST_NODE)
else if(node==LAST_NODE)
node=list->last;
if(node==NULL)
return(NULL);
......@@ -647,8 +643,6 @@ void* DLLCALL listRemoveNode(link_list_t* list, list_node_t* node, BOOL free_dat
if(node->flags&LINK_LIST_NODE_LOCKED)
return(NULL);
MUTEX_LOCK(list);
if(node->prev!=NULL)
node->prev->next = node->next;
if(node->next!=NULL)
......@@ -668,6 +662,20 @@ void* DLLCALL listRemoveNode(link_list_t* list, list_node_t* node, BOOL free_dat
if(list->count)
list->count--;
return(data);
}
void* DLLCALL listRemoveNode(link_list_t* list, list_node_t* node, BOOL free_data)
{
void* data;
if(list==NULL)
return(NULL);
MUTEX_LOCK(list);
data = list_remove_node(list, node, free_data);
MUTEX_UNLOCK(list);
return(data);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment