protected void CreateEdge(TunnelEdgeCallbackAction teca, List<Connection> overlap)
{
if(_connections.Contains(teca.TunnelTA.Target)) {
FailedEdgeCreate(teca);
return;
}
TunnelEdge te = null;
while(true) {
te = new TunnelEdge(this, (TunnelTransportAddress) _local_tas[0],
teca.TunnelTA, _iasf.GetForwarderSelector(), overlap);
lock(_sync) {
if(!_id_to_tunnel.ContainsKey(te.LocalID)) {
_id_to_tunnel[te.LocalID] = te;
break;
}
}
// Arriving here, implies another TunnelEdge will be created and this
// one needs to be closed
te.Close();
}
te.CloseEvent += CloseHandler;
teca.Success.Value = true;
teca.Exception.Value = null;
teca.Edge.Value = te;
_node.EnqueueAction(teca);
}