mirror of
https://github.com/deavminet/dnetd
synced 2024-09-21 17:53:39 +02:00
remove inbound server links when the connection breaks
This commit is contained in:
parent
6e75f84ba5
commit
4cd2528ca9
@ -227,7 +227,7 @@ public class DConnection : Thread
|
||||
{
|
||||
if(connType == ConnectionType.SERVER)
|
||||
{
|
||||
|
||||
server.getLinkManager().removeLinkInbounded(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -223,7 +223,7 @@ public final class DLink : Thread
|
||||
this(server, name, address=null);
|
||||
|
||||
/* Save connection */
|
||||
//this.connection = connection;
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
public string getName()
|
||||
@ -305,6 +305,38 @@ public final class DMeyer : Thread
|
||||
return linkGood;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Remove a link via DConnection (inbounded)
|
||||
*/
|
||||
public void removeLinkInbounded(DConnection connection)
|
||||
{
|
||||
linksMutex.lock();
|
||||
|
||||
DLink[] newList;
|
||||
DLink removedLink;
|
||||
foreach(DLink link; links)
|
||||
{
|
||||
if(link.connection != connection)
|
||||
{
|
||||
newList ~= link;
|
||||
}
|
||||
else
|
||||
{
|
||||
removedLink = link;
|
||||
}
|
||||
}
|
||||
|
||||
links = newList;
|
||||
|
||||
linksMutex.unlock();
|
||||
|
||||
gprintln("Removed inbounded peer from link manager "~to!(string)(removedLink));
|
||||
}
|
||||
|
||||
|
||||
public DLink[] getLinks()
|
||||
{
|
||||
return links;
|
||||
|
Loading…
Reference in New Issue
Block a user