Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix msg-bittorrent's problem of incompletion
authorNicolas Bonichon <bonichon@labri.fr>
Mon, 18 Mar 2013 14:53:43 +0000 (15:53 +0100)
committerNicolas Bonichon <bonichon@labri.fr>
Mon, 18 Mar 2013 15:16:26 +0000 (16:16 +0100)
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 [changed mode: 0644->0755]
examples/msg/bittorrent/peer.c

old mode 100644 (file)
new mode 100755 (executable)
index ec7df8a..8883469
@@ -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
index 4c930b7..632b19e 100644 (file)
@@ -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);