From e0e2a935f2d0f3c328089c0ea455882b24f2a7aa Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Thu, 11 Aug 2016 10:18:27 +0200 Subject: [PATCH] try to remove remaining blockers --- examples/java/cloud/masterworker/Worker.java | 12 +++++------- .../java/cloud/masterworker/cloud_masterworker.tesh | 4 ++-- examples/msg/app-bittorrent/peer.c | 8 +++++--- teshsuite/java/SleepHostOff/SleepHostOff.java | 6 ++++-- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/examples/java/cloud/masterworker/Worker.java b/examples/java/cloud/masterworker/Worker.java index 2220730fef..cf09aa9d89 100644 --- a/examples/java/cloud/masterworker/Worker.java +++ b/examples/java/cloud/masterworker/Worker.java @@ -20,20 +20,18 @@ public class Worker extends Process { } public void main(String[] args) throws MsgException { - Msg.info(this.getName() +" is listenning on MBOX:WRK0"+ number); + Msg.info(this.getName() +" is listening on MBOX:WRK0"+ number); while(true) { - Task task; + Task task =null; try { task = Task.receive("MBOX:WRK0"+number); + if (task == null) + break; } catch (MsgException e) { Msg.debug("Received failed. I'm done. See you!"); - break; } Msg.info("Received \"" + task.getName() + "\". Processing it."); - try { - task.execute(); - } catch (MsgException e) { - } + task.execute(); Msg.info(this.getName() +" executed task (" + task.getName()+")"); } } diff --git a/examples/java/cloud/masterworker/cloud_masterworker.tesh b/examples/java/cloud/masterworker/cloud_masterworker.tesh index 1ae841afbd..1aca080bda 100644 --- a/examples/java/cloud/masterworker/cloud_masterworker.tesh +++ b/examples/java/cloud/masterworker/cloud_masterworker.tesh @@ -12,8 +12,8 @@ $ java -classpath ${classpath:=.} cloud/masterworker/Main ${srcdir:=.}/../platfo > [ 0.000000] (1:Master@Jacquelin) Launched 2 VMs > [ 0.000000] (1:Master@Jacquelin) Send a first batch of work to everyone > [ 0.000000] (1:Master@Jacquelin) Sending to WRK00 -> [ 0.000000] (2:WRK00@VM00) WRK00 is listenning on MBOX:WRK00 -> [ 0.000000] (3:WRK01@VM01) WRK01 is listenning on MBOX:WRK01 +> [ 0.000000] (2:WRK00@VM00) WRK00 is listening on MBOX:WRK00 +> [ 0.000000] (3:WRK01@VM01) WRK01 is listening on MBOX:WRK01 > [ 0.892161] (1:Master@Jacquelin) Sending to WRK01 > [ 0.892161] (2:WRK00@VM00) Received "Task00". Processing it. > [ 0.892161] (2:WRK00@VM00) WRK00 executed task (Task00) diff --git a/examples/msg/app-bittorrent/peer.c b/examples/msg/app-bittorrent/peer.c index 09fd875317..de9affa8dc 100644 --- a/examples/msg/app-bittorrent/peer.c +++ b/examples/msg/app-bittorrent/peer.c @@ -619,10 +619,12 @@ void update_choked_peers(peer_t peer) i++; } xbt_dict_cursor_free(&cursor); - if ((peer_choosed->interested == 0) || - (peer_choosed->choked_upload == 0)) { + if (peer_choosed == NULL) + THROWF(unknown_error, 0, "A peer should have be selected at this point"); + else if ((peer_choosed->interested == 0) || (peer_choosed->choked_upload == 0)) peer_choosed = NULL; - } + else + XBT_DEBUG("Nothing to do, keep going"); j++; } while (peer_choosed == NULL && j < MAXIMUM_PAIRS); } else { diff --git a/teshsuite/java/SleepHostOff/SleepHostOff.java b/teshsuite/java/SleepHostOff/SleepHostOff.java index e57fb4a646..c48cca76b6 100644 --- a/teshsuite/java/SleepHostOff/SleepHostOff.java +++ b/teshsuite/java/SleepHostOff/SleepHostOff.java @@ -14,13 +14,15 @@ class Sleeper extends Process { super(host,name,args); } public void main(String[] args) { - while (true) { + boolean stillAlive = true; + while (stillAlive) { Msg.info("I'm not dead"); try { Process.sleep(10); + stillAlive = true; } catch (HostFailureException e) { + stillAlive = false; Msg.info("catch HostException: "+e.getLocalizedMessage()); - break; //Break is needed to finalize the endless loop } } } -- 2.20.1