Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Pull changes to push BitTorrent fix
authorMaximiliano Geier <maximiliano.geier@loria.fr>
Wed, 24 Oct 2012 12:57:28 +0000 (14:57 +0200)
committerMaximiliano Geier <maximiliano.geier@loria.fr>
Wed, 24 Oct 2012 12:57:28 +0000 (14:57 +0200)
examples/msg/bittorrent/bittorrent.tesh
examples/msg/bittorrent/messages.c
examples/msg/bittorrent/messages.h
examples/msg/bittorrent/peer.c

index a94ad65..669e486 100644 (file)
@@ -15,9 +15,9 @@ $ $SG_TEST_EXENV ${bindir:=.}/bittorrent ${srcdir:=.}/../msg_platform.xml ${srcd
 > [    0.000000] (8:peer@McGee) Hi, I'm joining the network with id 8
 > [ 3000.000000] (1:tracker@Jacquelin) Tracker is leaving
 > [ 5000.005340] (5:peer@Geoff) Here is my current status: 1111111111
-> [ 5000.012389] (7:peer@iRMX) Here is my current status: 1111111111
+> [ 5000.013261] (7:peer@iRMX) Here is my current status: 1111111111
 > [ 5000.048881] (2:peer@Boivin) Here is my current status: 1111111111
-> [ 5000.827195] (8:peer@McGee) Here is my current status: 1111111111
-> [ 5000.832370] (3:peer@Jean_Yves) Here is my current status: 1111111111
-> [ 5000.897047] (4:peer@TeX) Here is my current status: 1111111111
-> [ 5000.897047] (6:peer@Disney) Here is my current status: 1111111111
+> [ 5000.827966] (8:peer@McGee) Here is my current status: 1111111111
+> [ 5000.833962] (3:peer@Jean_Yves) Here is my current status: 1111111111
+> [ 5000.897269] (4:peer@TeX) Here is my current status: 1111111111
+> [ 5000.897269] (6:peer@Disney) Here is my current status: 1111111111
index 8eac54f..cf4759d 100644 (file)
@@ -8,7 +8,6 @@
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_messages, "Messages specific for the message factory");
 
-#define BYTES_TO_MB(x) ((long double)x/1048576.0)
 #define BITS_TO_BYTES(x) ((x / 8) + (x % 8) ? 1 : 0)
 
 /**
@@ -22,14 +21,13 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_messages, "Messages specific for the message fa
 msg_task_t task_message_new(e_message_type type, const char *issuer_host_name,
                             const char *mailbox, int peer_id, int size)
 {
-  long double size_mb = BYTES_TO_MB(size);
   message_t message = xbt_new(s_message_t, 1);
   message->issuer_host_name = issuer_host_name;
   message->peer_id = peer_id;
   message->mailbox = mailbox;
   message->type = type;
-  msg_task_t task = MSG_task_create(NULL, 0, size_mb, message);
-  XBT_DEBUG("type: %d size: %.20Lg (%d)", type, size_mb, size);
+  msg_task_t task = MSG_task_create(NULL, 0, size, message);
+  XBT_DEBUG("type: %d size: %.20Lg (%d)", type, size, size);
   return task;
 }
 
@@ -110,6 +108,7 @@ int task_message_size(e_message_type type)
     case MESSAGE_BITFIELD: size = MESSAGE_BITFIELD_SIZE; break;
     case MESSAGE_REQUEST: size = MESSAGE_REQUEST_SIZE; break;
     case MESSAGE_PIECE: size = MESSAGE_PIECE_SIZE; break;
+    case MESSAGE_CANCEL: size = MESSAGE_CANCEL_SIZE; break;
   }
   return size;
 }
index 2a87b7c..a8e98c3 100644 (file)
@@ -34,7 +34,8 @@ typedef enum {
   MESSAGE_HAVE,
   MESSAGE_BITFIELD,
   MESSAGE_REQUEST,
-  MESSAGE_PIECE
+  MESSAGE_PIECE,
+  MESSAGE_CANCEL
 } e_message_type;
 
 /**
index baa8bc1..f770a85 100644 (file)
@@ -428,6 +428,8 @@ void handle_message(peer_t peer, msg_task_t task)
       }
     }
     break;
+  case MESSAGE_CANCEL:
+    break;
   }
   //Update the peer speed.
   if (remote_peer) {