diff --git a/src/cmdu.c b/src/cmdu.c index 4c17be26679ac8c68e3fee152bb30db97e370dc0..167c6f387fb1475cdf72fbfe8e7d86ba1a82b094 100644 --- a/src/cmdu.c +++ b/src/cmdu.c @@ -15,6 +15,7 @@ #include <stdlib.h> #include <stdbool.h> #include <string.h> +#include <pthread.h> #include "util.h" #include "bufutil.h" diff --git a/src/cmdu.h b/src/cmdu.h index 34c17191b0b46fb660d09193e0837213b777c834..22008542091028e86544364eac1e3238db184bab 100644 --- a/src/cmdu.h +++ b/src/cmdu.h @@ -16,7 +16,6 @@ #define CMDU_H #include <stdint.h> -#include <pthread.h> #include <sys/time.h> #include <libubox/list.h> diff --git a/src/cmdu_input.c b/src/cmdu_input.c index f73a5cef08a8b3acbc2be05579c3bde7092202c2..5f00e81e115efb9ff9d4b30a3082fd85a5b49672 100644 --- a/src/cmdu_input.c +++ b/src/cmdu_input.c @@ -15,7 +15,6 @@ #include <string.h> #include <unistd.h> #include <fcntl.h> -#include <pthread.h> #include <sys/types.h> #include <sys/socket.h> diff --git a/src/cmdu_output.c b/src/cmdu_output.c index a793caae6c768a73e95a14028fa4c5877e8031ac..c7426e16e9580390ca96fc8b9a1b1580e7033730 100644 --- a/src/cmdu_output.c +++ b/src/cmdu_output.c @@ -16,7 +16,6 @@ #include <string.h> #include <unistd.h> #include <fcntl.h> -#include <pthread.h> #include <sys/types.h> #include <sys/socket.h> diff --git a/src/cmdufrag.c b/src/cmdufrag.c index 172bac9c8111bb7b314189b450a0211f28ec0d05..b454eda38771db61179bf20c992dce4c027b940b 100644 --- a/src/cmdufrag.c +++ b/src/cmdufrag.c @@ -15,6 +15,7 @@ #include <stdlib.h> #include <stdbool.h> #include <string.h> +#include <time.h> #include "debug.h" #include "timer.h" @@ -257,17 +258,14 @@ static struct cmdu_frag_rx *cmdufrag_lookup(void *rxfq, uint16_t type, struct cmdu_frag_rx *frag = NULL; - pthread_mutex_lock(&q->qlock); hlist_for_each_entry(frag, &q->table[idx], hlist) { if (frag->type == type && frag->mid == mid && !memcmp(frag->origin, origin, 6)) { if (frag->fid == fid) { - pthread_mutex_unlock(&q->qlock); return frag; } } } - pthread_mutex_unlock(&q->qlock); return NULL; } @@ -367,9 +365,7 @@ int cmdufrag_queue_enqueue(void *rxfq, struct cmdu_buff *cmdu, uint32_t timeout) if (frag) { int idx = cmdu_frag_hash(type, mid, origin); - pthread_mutex_lock(&q->qlock); q->pending_cnt++; - pthread_mutex_unlock(&q->qlock); fprintf(stderr, "ENQ: type = 0x%04x mid = %hu fid = %d origin = " MACFMT "\n", @@ -386,7 +382,6 @@ int cmdufrag_queue_enqueue(void *rxfq, struct cmdu_buff *cmdu, uint32_t timeout) return -1; } - pthread_mutex_lock(&q->qlock); firstfrag->last->next = frag; firstfrag->last = frag; firstfrag->tlen += frag->cmdu->datalen; @@ -398,11 +393,9 @@ int cmdufrag_queue_enqueue(void *rxfq, struct cmdu_buff *cmdu, uint32_t timeout) * If the first one ages-out, then all the related * fragments will be cleaned up. */ - pthread_mutex_unlock(&q->qlock); return 0; } - pthread_mutex_lock(&q->qlock); hlist_add_head(&frag->hlist, &q->table[idx]); if (timer_pending(&q->ageing_timer)) { @@ -418,7 +411,6 @@ int cmdufrag_queue_enqueue(void *rxfq, struct cmdu_buff *cmdu, uint32_t timeout) timer_set(&q->ageing_timer, frag->ageing_time); } - pthread_mutex_unlock(&q->qlock); return 0; } @@ -528,7 +520,6 @@ struct cmdu_buff *cmdu_defrag(void *rxfq, struct cmdu_buff *lastfrag) idx = cmdu_frag_hash(type, mid, origin); - pthread_mutex_lock(&q->qlock); hlist_for_each_entry_safe(frag, tmp, &q->table[idx], hlist) { if (frag->type == type && frag->mid == mid && !memcmp(frag->origin, origin, 6)) { @@ -542,7 +533,6 @@ struct cmdu_buff *cmdu_defrag(void *rxfq, struct cmdu_buff *lastfrag) break; } } - pthread_mutex_unlock(&q->qlock); if (!frag) return NULL; @@ -589,7 +579,6 @@ int cmdufrag_queue_init(void *rxfq) struct cmdufrag_queue *q = (struct cmdufrag_queue *)rxfq; memset(q, 0, sizeof(*q)); - pthread_mutex_init(&q->qlock, NULL); timer_init(&q->ageing_timer, cmdu_fragqueue_ageing_timer_run); return 0; @@ -601,7 +590,6 @@ void cmdufrag_queue_flush(void *rxfq) struct cmdu_frag_rx *msg = NULL; int idx = 0; - pthread_mutex_lock(&q->qlock); for (idx = 0; idx < NUM_FRAGMENTS; idx++) { hlist_for_each_entry(msg, &q->table[idx], hlist) cmdu_fragqueue_delete_chain(msg); @@ -610,7 +598,6 @@ void cmdufrag_queue_flush(void *rxfq) } q->pending_cnt = 0; - pthread_mutex_unlock(&q->qlock); } void cmdufrag_queue_free(void *rxfq) @@ -619,5 +606,4 @@ void cmdufrag_queue_free(void *rxfq) cmdufrag_queue_flush(q); timer_del(&q->ageing_timer); - pthread_mutex_destroy(&q->qlock); } diff --git a/src/cmdufrag.h b/src/cmdufrag.h index bce18e6448d58bbfc0a144d4ad79f6089ebbeb0a..05e4018905948b2c526640376894956c47391a31 100644 --- a/src/cmdufrag.h +++ b/src/cmdufrag.h @@ -15,7 +15,6 @@ #define CMDUFRAG_H #include <stdint.h> -#include <pthread.h> #include <sys/time.h> #include <libubox/list.h> @@ -59,7 +58,6 @@ struct cmdu_frag_rx { ((MAC_ADDR_HASH(o) ^ (t) ^ (m)) & (NUM_FRAGMENTS - 1)) struct cmdufrag_queue { - pthread_mutex_t qlock; struct hlist_head table[NUM_FRAGMENTS]; int pending_cnt; atimer_t ageing_timer; diff --git a/src/extensions/map/tests/mapclient.c b/src/extensions/map/tests/mapclient.c index e9dae31a12251849c05e07a96111d27c75f27cb2..69852f1fe55e77dbf89f3c4b21f2c778c3d57b5a 100644 --- a/src/extensions/map/tests/mapclient.c +++ b/src/extensions/map/tests/mapclient.c @@ -20,8 +20,6 @@ #include <sys/ioctl.h> #include <net/if_arp.h> -#include <pthread.h> - #include <easy/easy.h> #include "map_module.h" diff --git a/src/extensions/map/tests/mapclient1.c b/src/extensions/map/tests/mapclient1.c index 29b82585eb7cd70c744f4f3e42314456b2d62807..f6c68f0bef1a73055bfe8e35f938f1626f2fe074 100644 --- a/src/extensions/map/tests/mapclient1.c +++ b/src/extensions/map/tests/mapclient1.c @@ -20,8 +20,6 @@ #include <sys/ioctl.h> #include <net/if_arp.h> -#include <pthread.h> - #include <easy/easy.h> #include <1905_tlvs.h> diff --git a/src/extensions/map/tests/mapclient2.c b/src/extensions/map/tests/mapclient2.c index 25cc6f0a16846436f655a2ba0a841375c5eb0d16..a2f22577b2808e5281578b0a7f0c90cff9696397 100644 --- a/src/extensions/map/tests/mapclient2.c +++ b/src/extensions/map/tests/mapclient2.c @@ -20,8 +20,6 @@ #include <sys/ioctl.h> #include <net/if_arp.h> -#include <pthread.h> - #include <easy/easy.h> #include <1905_tlvs.h> diff --git a/src/i1905_al.c b/src/i1905_al.c index acea338eef41ec293173d09a0f6af4885173e76e..f92c24af7c3ff811be5630c5520314624ca69c8b 100644 --- a/src/i1905_al.c +++ b/src/i1905_al.c @@ -211,7 +211,6 @@ int i1905_dm_update_interface_self(struct i1905_private *p, list_flush(&iface->non1905_nbrlist, struct i1905_non1905_neighbor, list); iface->num_neighbor_non1905 = 0; - pthread_mutex_lock(&q->qlock); for (idx = 0; idx < NEIGH_ENTRIES_MAX; idx++) { hlist_for_each_entry(e, &q->table[idx], hlist) { if (e->is1905) @@ -248,7 +247,6 @@ int i1905_dm_update_interface_self(struct i1905_private *p, } } } - pthread_mutex_unlock(&q->qlock); } //fprintf(stderr, "Updating mediainfo for '%s'\n", iface->ifname); diff --git a/src/midgen.c b/src/midgen.c index 13209d8e2c3f66d97f123e7d6c8435fb16bf9dff..fa1de35ea0ea503892f2ab1aa2020558609ec352 100644 --- a/src/midgen.c +++ b/src/midgen.c @@ -12,8 +12,8 @@ #include <stdio.h> #include <stdlib.h> #include <stdint.h> -#include <pthread.h> #include <fcntl.h> +#include <time.h> #include <unistd.h> #include <semaphore.h> #include <sys/mman.h> diff --git a/src/neigh.c b/src/neigh.c index c1017c9fc85e4ce6e19305b05e6d2f308004910f..5f466e4657ba6463d2f6aaa784150a7c498aef01 100644 --- a/src/neigh.c +++ b/src/neigh.c @@ -9,7 +9,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <pthread.h> #include <easy/easy.h> @@ -215,7 +214,6 @@ int neigh_queue_init(void *nq) struct neigh_queue *q = (struct neigh_queue *)nq; memset(q, 0, sizeof(*q)); - pthread_mutex_init(&q->qlock, NULL); timer_init(&q->ageing_timer, neigh_ageing_timer_run); return 0; @@ -228,14 +226,11 @@ struct neigh_entry *neigh_lookup(void *nq, uint8_t *macaddr) struct neigh_entry *e = NULL; - pthread_mutex_lock(&q->qlock); hlist_for_each_entry(e, &q->table[idx], hlist) { if (!memcmp(e->macaddr, macaddr, 6)) { - pthread_mutex_unlock(&q->qlock); return e; } } - pthread_mutex_unlock(&q->qlock); return NULL; } @@ -248,7 +243,6 @@ int i1905_get_non1905_for_interface(void *nq, struct i1905_interface *iface) int i; - pthread_mutex_lock(&q->qlock); for (i = 0; i < NEIGH_ENTRIES_MAX; i++) { hlist_for_each_entry(e, &q->table[i], hlist) { if ((iface->brport && e->brport == iface->brport) || @@ -264,7 +258,6 @@ int i1905_get_non1905_for_interface(void *nq, struct i1905_interface *iface) } } } - pthread_mutex_unlock(&q->qlock); return 0; } @@ -277,7 +270,6 @@ struct neigh_entry *neigh_queue_print(void *nq) int idx = 0; - pthread_mutex_lock(&q->qlock); for (idx = 0; idx < NEIGH_ENTRIES_MAX; idx++) { hlist_for_each_entry(e, &q->table[idx], hlist) { struct ip_address_entry *t; @@ -302,7 +294,6 @@ struct neigh_entry *neigh_queue_print(void *nq) dbg7("%s", buf); } } - pthread_mutex_unlock(&q->qlock); return NULL; } @@ -313,7 +304,6 @@ void neigh_queue_flush(void *nq) struct neigh_entry *e = NULL; int idx = 0; - pthread_mutex_lock(&q->qlock); for (idx = 0; idx < NEIGH_ENTRIES_MAX; idx++) { hlist_for_each_entry(e, &q->table[idx], hlist) neigh_entry_delete(e); @@ -322,7 +312,6 @@ void neigh_queue_flush(void *nq) } q->pending_cnt = 0; - pthread_mutex_unlock(&q->qlock); } void neigh_queue_free(void *nq) @@ -331,7 +320,6 @@ void neigh_queue_free(void *nq) neigh_queue_flush(q); timer_del(&q->ageing_timer); - pthread_mutex_destroy(&q->qlock); } int ipaddr_equal(struct ip_address *a, struct ip_address *b) @@ -346,7 +334,6 @@ int ipaddr_equal(struct ip_address *a, struct ip_address *b) int neigh_set_type(void *nq, uint8_t *macaddr, enum neigh_type type) { - struct neigh_queue *q = (struct neigh_queue *)nq; struct neigh_entry *e = NULL; @@ -354,16 +341,13 @@ int neigh_set_type(void *nq, uint8_t *macaddr, enum neigh_type type) if (!e) return -1; - pthread_mutex_lock(&q->qlock); e->type = type; - pthread_mutex_unlock(&q->qlock); return 0; } uint16_t neigh_get_brport(void *nq, uint8_t *macaddr) { - struct neigh_queue *q = (struct neigh_queue *)nq; struct neigh_entry *e = NULL; uint16_t brport = 0xffff; @@ -372,16 +356,13 @@ uint16_t neigh_get_brport(void *nq, uint8_t *macaddr) if (!e) return 0xffff; - pthread_mutex_lock(&q->qlock); brport = e->brport; - pthread_mutex_unlock(&q->qlock); return brport; } int neigh_set_1905(void *nq, uint8_t *macaddr) { - struct neigh_queue *q = (struct neigh_queue *)nq; struct neigh_entry *e = NULL; @@ -389,16 +370,13 @@ int neigh_set_1905(void *nq, uint8_t *macaddr) if (!e) return -1; - pthread_mutex_lock(&q->qlock); e->is1905 = 1; - pthread_mutex_unlock(&q->qlock); return 0; } int neigh_set_1905_slave(void *nq, uint8_t *macaddr) { - struct neigh_queue *q = (struct neigh_queue *)nq; struct neigh_entry *e = NULL; @@ -406,16 +384,13 @@ int neigh_set_1905_slave(void *nq, uint8_t *macaddr) if (!e) return -1; - pthread_mutex_lock(&q->qlock); e->is1905_slave = 1; - pthread_mutex_unlock(&q->qlock); return 0; } bool is_neigh_1905(void *nq, uint8_t *macaddr) { - struct neigh_queue *q = (struct neigh_queue *)nq; struct neigh_entry *e = NULL; bool is1905; @@ -424,9 +399,7 @@ bool is_neigh_1905(void *nq, uint8_t *macaddr) if (!e) return false; - pthread_mutex_lock(&q->qlock); is1905 = e->is1905 == 1 ? true : false; - pthread_mutex_unlock(&q->qlock); return is1905; } @@ -450,7 +423,6 @@ int neigh_enqueue(void *nq, uint8_t *macaddr, uint16_t state, const char *ifname dbg("[%jd.%jd] Neigh " MACFMT " changed. state 0x%04x -> 0x%04x\n", (uintmax_t)tsp.tv_sec, (uintmax_t)tsp.tv_usec, MAC2STR(macaddr), e->state, state); - pthread_mutex_lock(&q->qlock); e->state = state; if (type != NEIGH_TYPE_UNKNOWN) e->type = type; @@ -493,7 +465,6 @@ int neigh_enqueue(void *nq, uint8_t *macaddr, uint16_t state, const char *ifname q->next_tmo.tv_usec = e->ageing_tmo.tv_usec; timer_set(&q->ageing_timer, e->ageing_time); } - pthread_mutex_unlock(&q->qlock); return 0; } @@ -504,7 +475,6 @@ int neigh_enqueue(void *nq, uint8_t *macaddr, uint16_t state, const char *ifname bool ipknown = false; - pthread_mutex_lock(&q->qlock); hlist_add_head(&e->hlist, &q->table[idx]); q->pending_cnt++; @@ -542,7 +512,6 @@ int neigh_enqueue(void *nq, uint8_t *macaddr, uint16_t state, const char *ifname } } - pthread_mutex_unlock(&q->qlock); return 1; /* XXX: when an entry gets added */ } @@ -565,11 +534,8 @@ int neigh_dequeue(void *nq, uint8_t *macaddr, void **cookie) idx = neigh_hash(macaddr); - pthread_mutex_lock(&q->qlock); hlist_del(&e->hlist, &q->table[idx]); q->pending_cnt--; - pthread_mutex_unlock(&q->qlock); - //fprintf(stderr, "DEQ: Entry " MACFMT "\n", MAC2STR(macaddr)); diff --git a/src/neigh.h b/src/neigh.h index 26f62fdd065e4f2cdb4711b1c4bdfa278917db21..636d17ed32eda75f997405768e4c0b659d0332a0 100644 --- a/src/neigh.h +++ b/src/neigh.h @@ -63,7 +63,6 @@ struct neigh_entry { }; struct neigh_queue { - pthread_mutex_t qlock; struct hlist_head table[NEIGH_ENTRIES_MAX]; int pending_cnt;