X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/f2d416e568c637bec46247643265b22045e6eed3:/examples/msg/app-bittorrent/connection.c..fad318e69b9130ad51b5bcff09362b1f162f5270:/teshsuite/msg/app-bittorrent/connection.c diff --git a/examples/msg/app-bittorrent/connection.c b/teshsuite/msg/app-bittorrent/connection.c similarity index 63% rename from examples/msg/app-bittorrent/connection.c rename to teshsuite/msg/app-bittorrent/connection.c index 43140e6fb8..3a53ed9cf6 100644 --- a/examples/msg/app-bittorrent/connection.c +++ b/teshsuite/msg/app-bittorrent/connection.c @@ -13,16 +13,16 @@ connection_t connection_new(int id) { connection_t connection = xbt_new(s_connection_t, 1); - connection->id = id; - connection->mailbox = bprintf("%d", id); - connection->bitfield = 0; - connection->current_piece = -1; - connection->interested = 0; - connection->am_interested = 0; - connection->choked_upload = 1; + connection->id = id; + connection->mailbox = bprintf("%d", id); + connection->bitfield = 0; + connection->current_piece = -1; + connection->interested = 0; + connection->am_interested = 0; + connection->choked_upload = 1; connection->choked_download = 1; - connection->peer_speed = 0; - connection->last_unchoke = 0; + connection->peer_speed = 0; + connection->last_unchoke = 0; return connection; } @@ -32,13 +32,14 @@ void connection_add_speed_value(connection_t connection, double speed) connection->peer_speed = connection->peer_speed * 0.6 + speed * 0.4; } -void connection_free(void *data) +void connection_free(void* data) { - connection_t co = (connection_t) data; + connection_t co = (connection_t)data; xbt_free(co->mailbox); xbt_free(co); } -int connection_has_piece(connection_t connection, unsigned int piece){ - return (connection->bitfield & 1U<bitfield & 1U << piece); }