From d36f84b566b47c107a58ac26c5f3886feb1db61c Mon Sep 17 00:00:00 2001 From: Nicolas Bonichon Date: Mon, 18 Mar 2013 15:53:43 +0100 Subject: [PATCH] Fix msg-bittorrent's problem of incompletion In the previous version, a peer wasn't able to handle more than more message per second but could receive much more. As a consequence, the application gets stuck because of queuing issue. The problem comes from teh main loops (leech_loop() and seed_loop())) each call of MSG_task_irecv() was followed by a call of MSG_process_sleep(1) because the MSG_comm_test() always fails the first time. A call of MSG_mailbox_set_async() at the begining fixes this problem. : in the main loops (leech_loop) --- examples/msg/bittorrent/bittorrent.tesh | 10 +++++----- examples/msg/bittorrent/peer.c | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) mode change 100644 => 100755 examples/msg/bittorrent/bittorrent.tesh diff --git a/examples/msg/bittorrent/bittorrent.tesh b/examples/msg/bittorrent/bittorrent.tesh old mode 100644 new mode 100755 index ec7df8ab1f..8883469d4e --- a/examples/msg/bittorrent/bittorrent.tesh +++ b/examples/msg/bittorrent/bittorrent.tesh @@ -14,10 +14,10 @@ $ $SG_TEST_EXENV ${bindir:=.}/bittorrent ${srcdir:=.}/../msg_platform.xml ${srcd > [ 0.000000] (7:peer@iRMX) Hi, I'm joining the network with id 7 > [ 0.000000] (8:peer@McGee) Hi, I'm joining the network with id 8 > [ 3000.000000] (1:tracker@Jacquelin) Tracker is leaving +> [ 5000.002839] (3:peer@Jean_Yves) Here is my current status: 1111111111 > [ 5000.005340] (5:peer@Geoff) Here is my current status: 1111111111 -> [ 5000.012635] (7:peer@iRMX) Here is my current status: 1111111111 > [ 5000.048881] (2:peer@Boivin) Here is my current status: 1111111111 -> [ 5000.827441] (8:peer@McGee) Here is my current status: 1111111111 -> [ 5000.832977] (3:peer@Jean_Yves) Here is my current status: 1111111111 -> [ 5000.897268] (4:peer@TeX) Here is my current status: 1111111111 -> [ 5000.897268] (6:peer@Disney) Here is my current status: 1111111111 +> [ 5000.177031] (4:peer@TeX) Here is my current status: 1111111111 +> [ 5000.201645] (6:peer@Disney) Here is my current status: 1111111111 +> [ 5000.408123] (7:peer@iRMX) Here is my current status: 1111111111 +> [ 5000.888352] (8:peer@McGee) Here is my current status: 1111111111 diff --git a/examples/msg/bittorrent/peer.c b/examples/msg/bittorrent/peer.c index 4c930b74d9..632b19e0a0 100644 --- a/examples/msg/bittorrent/peer.c +++ b/examples/msg/bittorrent/peer.c @@ -48,6 +48,7 @@ int peer(int argc, char *argv[]) XBT_DEBUG("Got %d peers from the tracker", xbt_dict_length(peer.peers)); XBT_DEBUG("Here is my current status: %s", peer.bitfield); peer.begin_receive_time = MSG_get_clock(); + MSG_mailbox_set_async(peer.mailbox); if (has_finished(peer.bitfield)) { peer.pieces = FILE_PIECES; send_handshake_all(&peer); -- 2.20.1