summaryrefslogtreecommitdiff
path: root/locking.h
diff options
context:
space:
mode:
authorVadim Kochan <vadim4j@gmail.com>2015-03-22 13:48:50 +0200
committerTobias Klauser <tklauser@distanz.ch>2015-03-30 14:08:50 +0200
commitdd5d906c40db5264d8d33c37565b39540f0258c8 (patch)
tree8f4205351a4f104c6ebf0e883f58546738fb9e6f /locking.h
parent895fdbb7d6b01e207103c8924c1c853f0fafee15 (diff)
mz: Make access to pcap init functions thread safe
mz fails to start in cli mode and prints each time different pcap errors: $ mz -x -V fatal flex scanner internal error--end of buffer missed rx_arp: [ERROR] Error calling pcap_compile or simply shuts down. Sometimes it successfully gets up. Seems some initialization pcap functions are not thread safer. Fixed by using mutex locking before entering pcap_loop() Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'locking.h')
-rw-r--r--locking.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/locking.h b/locking.h
index cb57a9d..2cb93d1 100644
--- a/locking.h
+++ b/locking.h
@@ -11,6 +11,8 @@ struct mutexlock {
pthread_mutex_t lock;
};
+#define MUTEXLOCK_INITIALIZER { .lock = PTHREAD_MUTEX_INITIALIZER }
+
struct rwlock {
pthread_rwlock_t lock;
};