mirror of
https://github.com/ChronosX88/KademliaDHT.git
synced 2024-11-21 17:52:21 +00:00
Synchronization
- We were getting some concurrency exceptions because certain data structures were being modified concurrently - Solved the issues by synchronizing the methods modifying the data structures
This commit is contained in:
parent
cb42c507de
commit
1e2cc037de
@ -80,7 +80,7 @@ public class DHT
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
*/
|
||||
public boolean store(StorageEntry content) throws IOException
|
||||
public synchronized boolean store(StorageEntry content) throws IOException
|
||||
{
|
||||
/* Lets check if we have this content and it's the updated version */
|
||||
if (this.entriesManager.contains(content.getContentMetadata()))
|
||||
@ -142,7 +142,7 @@ public class DHT
|
||||
|
||||
}
|
||||
|
||||
public boolean store(KadContent content) throws IOException
|
||||
public synchronized boolean store(KadContent content) throws IOException
|
||||
{
|
||||
return this.store(new StorageEntry(content));
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ class StoredContentManager
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean contains(GetParameter param)
|
||||
public synchronized boolean contains(GetParameter param)
|
||||
{
|
||||
if (this.entries.containsKey(param.getKey()))
|
||||
{
|
||||
@ -93,7 +93,7 @@ class StoredContentManager
|
||||
/**
|
||||
* Check if a content exist in the DHT
|
||||
*/
|
||||
public boolean contains(KadContent content)
|
||||
public synchronized boolean contains(KadContent content)
|
||||
{
|
||||
return this.contains(new GetParameter(content));
|
||||
}
|
||||
@ -101,7 +101,7 @@ class StoredContentManager
|
||||
/**
|
||||
* Check if a StorageEntry exist on this DHT
|
||||
*/
|
||||
public boolean contains(StorageEntryMetadata entry)
|
||||
public synchronized boolean contains(StorageEntryMetadata entry)
|
||||
{
|
||||
return this.contains(new GetParameter(entry));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user