routing fix
This commit is contained in:
parent
4903014ebd
commit
ecf4f9c719
@ -12,10 +12,6 @@ class Init {
|
||||
public static function initKernel() {
|
||||
// Init singeltons here because haxe is confused about the order to create them.
|
||||
KernelEvents.instance = new KernelEvents();
|
||||
MainLoop.add(() -> {
|
||||
KernelEvents.instance.startEventLoop();
|
||||
},1);
|
||||
|
||||
Peripheral.instance = new Peripheral();
|
||||
|
||||
WindowManager.instance = new WindowManager();
|
||||
@ -25,8 +21,6 @@ class Init {
|
||||
Routing.instance = new Routing();
|
||||
Net.instance = new Net();
|
||||
|
||||
Routing.instance.init();
|
||||
|
||||
// Register default terminate handler
|
||||
KernelEvents.instance.onTerminate.handle(_->{
|
||||
OS.reboot();
|
||||
@ -34,7 +28,13 @@ class Init {
|
||||
|
||||
Debug.printBuildInfo();
|
||||
|
||||
|
||||
Log.moveToOutput("main");
|
||||
|
||||
Routing.instance.init();
|
||||
|
||||
MainLoop.add(()->{
|
||||
KernelEvents.instance.startEventLoop();
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +74,11 @@ class Routing {
|
||||
data: null
|
||||
}
|
||||
|
||||
interf.send(pack.fromID,Net.instance.networkID,response);
|
||||
// HACK: Because Lua is singelthreaded the computer we respond to can get overwhelmed with
|
||||
// the responses and can swollow events.
|
||||
new Timer(Net.instance.networkID / 3,()->{
|
||||
interf.send(response.toID,Net.instance.networkID,response);
|
||||
});
|
||||
}
|
||||
|
||||
private function genRouteList(): Array<{id:NetworkID,cost:Int}> {
|
||||
@ -109,18 +113,16 @@ class Routing {
|
||||
return;
|
||||
}
|
||||
|
||||
Log.debug("a");
|
||||
|
||||
var fullCost = cost+interf.getBaseRoutingCost();
|
||||
|
||||
if (this.routingTable.exists(toID)){
|
||||
if (this.routingTable[toID].cost > fullCost){
|
||||
Log.debug("Better route: " + toID + " -> " + interf.name() + ":$"+fullCost);
|
||||
Log.info("Better route: " + toID + " -> " + interf.name() + ":$"+fullCost);
|
||||
this.routingTable[toID] = {interf:interf,cost:cost + interf.getBaseRoutingCost()};
|
||||
}
|
||||
}else{
|
||||
this.routingTable[toID] = {interf:interf,cost:cost + interf.getBaseRoutingCost()};
|
||||
Log.debug("New route: " + toID + " -> " + interf.name() + ":$"+fullCost);
|
||||
Log.info("New route: " + toID + " -> " + interf.name() + ":$"+fullCost);
|
||||
this.onNewNeigborTrigger.trigger(toID);
|
||||
}
|
||||
}
|
||||
|
@ -21,8 +21,8 @@ class Modem implements INetworkInterface implements IPeripheral {
|
||||
KernelEvents.instance.onModemMessage.handle(params ->{
|
||||
if (params.addr == this.addr){
|
||||
var pack:Package = {
|
||||
fromID: params.replyChannel,
|
||||
toID: params.channel,
|
||||
fromID: params.message.fromID,
|
||||
toID: params.message.toID,
|
||||
msgID: params.message.msgID,
|
||||
type: params.message.type,
|
||||
data: params.message.data,
|
||||
|
Loading…
Reference in New Issue
Block a user