mirror of
https://github.com/deavminet/dnetd
synced 2024-09-21 17:53:39 +02:00
Removed outbounded peers on read error
This commit is contained in:
parent
4cd2528ca9
commit
e18d7b59b5
@ -139,8 +139,22 @@ public final class DLink : Thread
|
|||||||
/* TODO: Implement me */
|
/* TODO: Implement me */
|
||||||
while(true)
|
while(true)
|
||||||
{
|
{
|
||||||
|
byte[] dataIn;
|
||||||
|
bool statusRecv = bReceiveMessage(outboundSocket, dataIn);
|
||||||
|
|
||||||
|
if(statusRecv)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* TODO: Connection error */
|
||||||
|
gprintln("Outbound server communication error, breaking", DebugType.ERROR);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO: Clean up connection */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -276,6 +290,37 @@ public final class DMeyer : Thread
|
|||||||
linksMutex = new Mutex();
|
linksMutex = new Mutex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void removeLinkOutbounded(string serverName)
|
||||||
|
{
|
||||||
|
/* Lock the links list */
|
||||||
|
linksMutex.lock();
|
||||||
|
|
||||||
|
DLink[] newList;
|
||||||
|
DLink removedLink;
|
||||||
|
foreach(DLink link; links)
|
||||||
|
{
|
||||||
|
if(cmp(link.getName(), serverName) != 0)
|
||||||
|
{
|
||||||
|
newList ~= link;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
removedLink = link;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
links = newList;
|
||||||
|
|
||||||
|
|
||||||
|
/* Unlock the links list */
|
||||||
|
linksMutex.unlock();
|
||||||
|
|
||||||
|
|
||||||
|
gprintln("Removed outbounded peer "~to!(string)(removedLink), DebugType.WARNING);
|
||||||
|
}
|
||||||
|
|
||||||
public bool attachLink(string serverName, DLink link)
|
public bool attachLink(string serverName, DLink link)
|
||||||
{
|
{
|
||||||
/* Link exists? */
|
/* Link exists? */
|
||||||
@ -333,7 +378,7 @@ public final class DMeyer : Thread
|
|||||||
|
|
||||||
linksMutex.unlock();
|
linksMutex.unlock();
|
||||||
|
|
||||||
gprintln("Removed inbounded peer from link manager "~to!(string)(removedLink));
|
gprintln("Removed inbounded peer from link manager "~to!(string)(removedLink), DebugType.WARNING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user