Skip to content

Commit

Permalink
Add mutex for fix autoconfig renew after handle timeout reduce
Browse files Browse the repository at this point in the history
Author: AswiniViswanathan <[email protected]>
  • Loading branch information
abhijithtk17 authored and soumyasmunshi committed Dec 31, 2024
1 parent 00b868a commit 351902b
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/em/em_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ void em_mgr_t::delete_node(em_interface_t *ruid)

em->stop();
em->deinit();
hash_map_remove(m_em_map, mac_str);
pthread_mutex_lock(&m_mutex);
hash_map_remove(m_em_map, mac_str);
pthread_mutex_unlock(&m_mutex);
delete em;

}
Expand Down Expand Up @@ -130,7 +132,9 @@ em_t *em_mgr_t::create_node(em_interface_t *ruid, em_freq_band_t band, dm_easy_m
}

// add this em to hash map
pthread_mutex_lock(&m_mutex);
hash_map_put(m_em_map, strdup(mac_str), em);
pthread_mutex_unlock(&m_mutex);
printf("%s:%d: created entry for key:%s\n", __func__, __LINE__, mac_str);

return em;
Expand Down Expand Up @@ -214,7 +218,7 @@ void em_mgr_t::nodes_listener()
{
em_t *em = NULL;
struct timeval tm;
int rc, len, highest_fd = 0;
int rc, len, highest_fd = 0, ret = 0;
unsigned char buff[MAX_EM_BUFF_SZ];
em_raw_hdr_t *hdr;

Expand All @@ -234,7 +238,10 @@ void em_mgr_t::nodes_listener()
em = (em_t *)hash_map_get_first(m_em_map);
while (em != NULL) {
if (em->is_al_interface_em() == true) {
if (FD_ISSET(em->get_fd(), &m_rset)) {
pthread_mutex_lock(&m_mutex);
ret = FD_ISSET(em->get_fd(), &m_rset);
pthread_mutex_unlock(&m_mutex);
if (ret) {
// receive data from this interface
memset(buff, 0, MAX_EM_BUFF_SZ);
len = read(em->get_fd(), buff, MAX_EM_BUFF_SZ);
Expand Down

0 comments on commit 351902b

Please sign in to comment.