From 8a7480e3563da7ae0eeb44e10e71c0d7535594d6 Mon Sep 17 00:00:00 2001 From: "Tristan B. Kildaire" Date: Tue, 20 Oct 2020 09:57:50 +0200 Subject: [PATCH] Added mutex for properties to `isProperty` and `getProperty` --- source/dnetd/dconnection.d | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/source/dnetd/dconnection.d b/source/dnetd/dconnection.d index 3f519e5..3d6edfb 100644 --- a/source/dnetd/dconnection.d +++ b/source/dnetd/dconnection.d @@ -909,7 +909,14 @@ public class DConnection : Thread */ public void setProperty(string propertyName, string propertyValue) { + /* Lock the properties store */ + propertiesLock.lock(); + + /* Set the property's value */ properties[propertyName] = propertyValue; + + /* Unlock the properties store */ + propertiesLock.unlock(); } /** @@ -918,7 +925,22 @@ public class DConnection : Thread */ public bool isProperty(string propertyName) { - return cast(bool)(propertyName in properties); + /** + * Whether or not the given property is a property + * of this user + */ + bool status; + + /* Lock the properties store */ + propertiesLock.lock(); + + /* Check for the property's existence */ + status = cast(bool)(propertyName in properties); + + /* Unlock the properties store */ + propertiesLock.unlock(); + + return status; } /**