diff options
author | Sander Vrijders <sander.vrijders@ugent.be> | 2017-08-29 16:58:11 +0200 |
---|---|---|
committer | Sander Vrijders <sander.vrijders@ugent.be> | 2017-08-29 17:51:38 +0200 |
commit | 407f1e70cedcf8d7694a5fefa5faf3225abebc81 (patch) | |
tree | 8b5e53f8eddc06beddec927d6a506e3c55fca0b3 /src/ipcpd/shim-eth-llc | |
parent | 00aeb6ee00efa98c7e2d6d9bebeb1c4799ba1705 (diff) | |
download | ouroboros-407f1e70cedcf8d7694a5fefa5faf3225abebc81.tar.gz ouroboros-407f1e70cedcf8d7694a5fefa5faf3225abebc81.zip |
shim-eth-llc: Hide directory query locking
The locking of the directory queries was happening in the
shim-eth-llc, but it should be done within the shim-data functions.
Fixes #30
Diffstat (limited to 'src/ipcpd/shim-eth-llc')
-rw-r--r-- | src/ipcpd/shim-eth-llc/main.c | 26 |
1 files changed, 4 insertions, 22 deletions
diff --git a/src/ipcpd/shim-eth-llc/main.c b/src/ipcpd/shim-eth-llc/main.c index e5f0cba8..b8e987ba 100644 --- a/src/ipcpd/shim-eth-llc/main.c +++ b/src/ipcpd/shim-eth-llc/main.c @@ -512,24 +512,13 @@ static int eth_llc_ipcp_name_query_req(const uint8_t * hash, static int eth_llc_ipcp_name_query_reply(const uint8_t * hash, uint8_t * r_addr) { - uint64_t address = 0; - struct list_head * pos; + uint64_t address = 0; memcpy(&address, r_addr, MAC_SIZE); shim_data_dir_add_entry(eth_llc_data.shim_data, hash, address); - pthread_mutex_lock(ð_llc_data.shim_data->dir_queries_lock); - - list_for_each(pos, ð_llc_data.shim_data->dir_queries) { - struct dir_query * e = - list_entry(pos, struct dir_query, next); - if (memcmp(e->hash, hash, ipcp_dir_hash_len()) == 0) { - shim_data_dir_query_respond(e); - } - } - - pthread_mutex_unlock(ð_llc_data.shim_data->dir_queries_lock); + shim_data_dir_query_respond(eth_llc_data.shim_data, hash); return 0; } @@ -1053,22 +1042,15 @@ static int eth_llc_ipcp_query(const uint8_t * hash) memset(r_addr, 0xff, MAC_SIZE); - query = shim_data_dir_query_create(hash); + query = shim_data_dir_query_create(eth_llc_data.shim_data, hash); if (query == NULL) return -1; - pthread_mutex_lock(ð_llc_data.shim_data->dir_queries_lock); - list_add(&query->next, ð_llc_data.shim_data->dir_queries); - pthread_mutex_unlock(ð_llc_data.shim_data->dir_queries_lock); - eth_llc_ipcp_send_mgmt_frame(&msg, r_addr); ret = shim_data_dir_query_wait(query, &timeout); - pthread_mutex_lock(ð_llc_data.shim_data->dir_queries_lock); - list_del(&query->next); - shim_data_dir_query_destroy(query); - pthread_mutex_unlock(ð_llc_data.shim_data->dir_queries_lock); + shim_data_dir_query_destroy(eth_llc_data.shim_data, query); return ret; } |