#ifndef _HAPROXY_GUID_H
#define _HAPROXY_GUID_H
+#include <haproxy/api-t.h>
#include <haproxy/guid-t.h>
+#include <haproxy/thread-t.h>
+
+__decl_thread(extern HA_RWLOCK_T guid_lock);
void guid_init(struct guid_node *node);
int guid_insert(enum obj_type *obj_type, const char *uid, char **errmsg);
#include <haproxy/proxy.h>
#include <haproxy/server-t.h>
#include <haproxy/tools.h>
+#include <haproxy/thread.h>
/* GUID global tree */
struct eb_root guid_tree = EB_ROOT_UNIQUE;
+__decl_thread(HA_RWLOCK_T guid_lock);
/* Initialize <guid> members. */
void guid_init(struct guid_node *guid)
}
guid->node.key = key;
+
+ HA_RWLOCK_WRLOCK(GUID_LOCK, &guid_lock);
node = ebis_insert(&guid_tree, &guid->node);
if (node != &guid->node) {
dup = ebpt_entry(node, struct guid_node, node);
+ HA_RWLOCK_WRUNLOCK(GUID_LOCK, &guid_lock);
dup_name = guid_name(dup);
memprintf(errmsg, "duplicate entry with %s", dup_name);
goto err;
}
+ HA_RWLOCK_WRUNLOCK(GUID_LOCK, &guid_lock);
guid->obj_type = objt;
return 0;
*/
void guid_remove(struct guid_node *guid)
{
+ HA_RWLOCK_WRLOCK(GUID_LOCK, &guid_lock);
ebpt_delete(&guid->node);
ha_free(&guid->node.key);
+ HA_RWLOCK_WRUNLOCK(GUID_LOCK, &guid_lock);
}
/* Retrieve an instance from GUID global tree with key <uid>.
struct ebpt_node *node = NULL;
struct guid_node *guid = NULL;
+ /* For now, guid_lookup() is only used during startup in single-thread
+ * mode. If this is not the case anymore, GUID tree access must be
+ * protected with the read-write lock.
+ */
+ BUG_ON(!(global.mode & MODE_STARTING));
+
node = ebis_lookup(&guid_tree, uid);
if (node)
guid = ebpt_entry(node, struct guid_node, node);
case OCSP_LOCK: return "OCSP";
case QC_CID_LOCK: return "QC_CID";
case CACHE_LOCK: return "CACHE";
+ case GUID_LOCK: return "GUID";
case OTHER_LOCK: return "OTHER";
case DEBUG1_LOCK: return "DEBUG1";
case DEBUG2_LOCK: return "DEBUG2";