MEDIUM: thread/vars: Make vars thread-safe

A RW lock has been added to the vars structure to protect each list of
variables. And a global RW lock is used to protect registered names.

When a varibable is fetched, we duplicate sample data because the variable could
be modified by another thread.
diff --git a/include/types/vars.h b/include/types/vars.h
index cd1620c..8a4f7aa 100644
--- a/include/types/vars.h
+++ b/include/types/vars.h
@@ -2,6 +2,7 @@
 #define _TYPES_VARS_H
 
 #include <common/mini-clist.h>
+#include <common/hathreads.h>
 
 #include <types/sample.h>
 
@@ -17,6 +18,9 @@
 	struct list head;
 	enum vars_scope scope;
 	unsigned int size;
+#ifdef USE_THREAD
+	HA_RWLOCK_T rwlock;
+#endif
 };
 
 /* This struct describes a variable. */