mirror of
https://github.com/ChronosX88/KademliaDHT.git
synced 2024-11-22 10:12:19 +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
|
* @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 */
|
/* Lets check if we have this content and it's the updated version */
|
||||||
if (this.entriesManager.contains(content.getContentMetadata()))
|
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));
|
return this.store(new StorageEntry(content));
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ class StoredContentManager
|
|||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public boolean contains(GetParameter param)
|
public synchronized boolean contains(GetParameter param)
|
||||||
{
|
{
|
||||||
if (this.entries.containsKey(param.getKey()))
|
if (this.entries.containsKey(param.getKey()))
|
||||||
{
|
{
|
||||||
@ -93,7 +93,7 @@ class StoredContentManager
|
|||||||
/**
|
/**
|
||||||
* Check if a content exist in the DHT
|
* 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));
|
return this.contains(new GetParameter(content));
|
||||||
}
|
}
|
||||||
@ -101,7 +101,7 @@ class StoredContentManager
|
|||||||
/**
|
/**
|
||||||
* Check if a StorageEntry exist on this DHT
|
* 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));
|
return this.contains(new GetParameter(entry));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user