Skip to content

Commit

Permalink
Merge pull request #185 from flaviojs/fix-data-race-netio_rxl_add-net…
Browse files Browse the repository at this point in the history
…io_rxl_remove

Fix data race in netio_rxl_add and netio_rxl_remove.
  • Loading branch information
grossmj authored Mar 24, 2024
2 parents d671df2 + e42e831 commit 2bac780
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions common/net_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -1703,8 +1703,9 @@ int netio_rxl_add(netio_desc_t *nio,netio_rx_handler_t rx_handler,

rxl->next = netio_rxl_add_list;
netio_rxl_add_list = rxl;

pthread_cond_wait(&netio_rxl_cond,&netio_rxq_mutex);
while(netio_rxl_add_list != NULL) {
pthread_cond_wait(&netio_rxl_cond,&netio_rxq_mutex);
}
NETIO_RXQ_UNLOCK();
return(0);
}
Expand All @@ -1715,7 +1716,9 @@ int netio_rxl_remove(netio_desc_t *nio)
NETIO_RXQ_LOCK();
nio->rxl_next = netio_rxl_remove_list;
netio_rxl_remove_list = nio;
pthread_cond_wait(&netio_rxl_cond,&netio_rxq_mutex);
while(netio_rxl_remove_list != NULL) {
pthread_cond_wait(&netio_rxl_cond,&netio_rxq_mutex);
}
NETIO_RXQ_UNLOCK();
return(0);
}
Expand Down

0 comments on commit 2bac780

Please sign in to comment.