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)
> [ 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
> [ 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.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.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
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();
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);
if (has_finished(peer.bitfield)) {
peer.pieces = FILE_PIECES;
send_handshake_all(&peer);