NetworkAddressResolver: cache needs to be locked

It is not a good idea to have a thread get an address from the request
cache, while another thread is deleting said address as the cache has
grown too large. Add a lock around the cache access to make it safe.
This commit is contained in:
Adrien Destugues
2017-11-21 22:15:32 +01:00
parent 4c99992724
commit b140a1c340
2 changed files with 16 additions and 4 deletions
+3 -1
View File
@@ -1,11 +1,12 @@
/*
* Copyright 2010, Haiku, Inc. All Rights Reserved.
* Copyright 2010-2017, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _NETWORK_ADDRESS_RESOLVER_H
#define _NETWORK_ADDRESS_RESOLVER_H
#include <Locker.h>
#include <ObjectList.h>
#include <Referenceable.h>
#include <String.h>
@@ -103,6 +104,7 @@ private:
BReference<const BNetworkAddressResolver> fResolver;
};
static BLocker sCacheLock;
static BObjectList<CacheEntry> sCacheMap;
};