diff options
author | Bart Polot <bart@net.in.tum.de> | 2011-09-29 23:18:16 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2011-09-29 23:18:16 +0000 |
commit | 7cf917fadf26d0e69bac1259b8b9585eb24c7b96 (patch) | |
tree | bdc181e4bd5c52220403b7a9e2e89aaec736b8ae /src/mesh | |
parent | 9e9b505c9294b2975effc6d4c7df8aaa2f6abead (diff) | |
download | gnunet-7cf917fadf26d0e69bac1259b8b9585eb24c7b96.tar.gz gnunet-7cf917fadf26d0e69bac1259b8b9585eb24c7b96.zip |
Fixed multicast retransmission, fixed memory managemenet at path creation
Diffstat (limited to 'src/mesh')
-rw-r--r-- | src/mesh/gnunet-service-mesh.c | 89 |
1 files changed, 68 insertions, 21 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index 0d3d0211b..86030c05b 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c | |||
@@ -557,7 +557,7 @@ announce_id (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
557 | GNUNET_DHT_RO_RECORD_ROUTE, /* DHT options */ | 557 | GNUNET_DHT_RO_RECORD_ROUTE, /* DHT options */ |
558 | GNUNET_BLOCK_TYPE_TEST, /* Block type */ | 558 | GNUNET_BLOCK_TYPE_TEST, /* Block type */ |
559 | sizeof(my_full_id), /* Size of the data */ | 559 | sizeof(my_full_id), /* Size of the data */ |
560 | &my_full_id, /* Data itself */ | 560 | (char *)&my_full_id, /* Data itself */ |
561 | GNUNET_TIME_absolute_get_forever (), /* Data expiration */ | 561 | GNUNET_TIME_absolute_get_forever (), /* Data expiration */ |
562 | GNUNET_TIME_UNIT_FOREVER_REL, /* Retry time */ | 562 | GNUNET_TIME_UNIT_FOREVER_REL, /* Retry time */ |
563 | #if MESH_DEBUG | 563 | #if MESH_DEBUG |
@@ -1042,10 +1042,9 @@ notify_peer_disconnected (const struct MeshTunnelTreeNode *n) | |||
1042 | * @param peer PeerInfo of the peer being added | 1042 | * @param peer PeerInfo of the peer being added |
1043 | * | 1043 | * |
1044 | */ | 1044 | */ |
1045 | void | 1045 | static void |
1046 | tunnel_add_peer (struct MeshTunnel *t, struct MeshPeerInfo *peer) | 1046 | tunnel_add_peer (struct MeshTunnel *t, struct MeshPeerInfo *peer) |
1047 | { | 1047 | { |
1048 | // struct MeshTunnelTreeNode *n; | ||
1049 | struct MeshPeerPath *p; | 1048 | struct MeshPeerPath *p; |
1050 | struct MeshPeerPath *best_p; | 1049 | struct MeshPeerPath *best_p; |
1051 | unsigned int best_cost; | 1050 | unsigned int best_cost; |
@@ -1080,6 +1079,7 @@ tunnel_add_peer (struct MeshTunnel *t, struct MeshPeerInfo *peer) | |||
1080 | if (GNUNET_SCHEDULER_NO_TASK == t->path_refresh_task) | 1079 | if (GNUNET_SCHEDULER_NO_TASK == t->path_refresh_task) |
1081 | t->path_refresh_task = | 1080 | t->path_refresh_task = |
1082 | GNUNET_SCHEDULER_add_delayed (t->tree->refresh, &path_refresh, t); | 1081 | GNUNET_SCHEDULER_add_delayed (t->tree->refresh, &path_refresh, t); |
1082 | |||
1083 | } | 1083 | } |
1084 | 1084 | ||
1085 | 1085 | ||
@@ -1298,8 +1298,6 @@ send_core_data_to_origin (void *cls, size_t size, void *buf) | |||
1298 | * @param buf where the callee should write the message | 1298 | * @param buf where the callee should write the message |
1299 | * | 1299 | * |
1300 | * @return number of bytes written to buf | 1300 | * @return number of bytes written to buf |
1301 | * | ||
1302 | * FIXME path | ||
1303 | */ | 1301 | */ |
1304 | static size_t | 1302 | static size_t |
1305 | send_core_data_multicast (void *cls, size_t size, void *buf) | 1303 | send_core_data_multicast (void *cls, size_t size, void *buf) |
@@ -1309,31 +1307,44 @@ send_core_data_multicast (void *cls, size_t size, void *buf) | |||
1309 | size_t total_size; | 1307 | size_t total_size; |
1310 | 1308 | ||
1311 | GNUNET_assert (NULL != info); | 1309 | GNUNET_assert (NULL != info); |
1310 | GNUNET_assert (NULL != info->peer); | ||
1312 | total_size = info->size + sizeof (struct GNUNET_MESH_Multicast); | 1311 | total_size = info->size + sizeof (struct GNUNET_MESH_Multicast); |
1313 | GNUNET_assert (total_size < GNUNET_SERVER_MAX_MESSAGE_SIZE); | 1312 | GNUNET_assert (total_size < GNUNET_SERVER_MAX_MESSAGE_SIZE); |
1314 | 1313 | ||
1315 | if (info->peer) | ||
1316 | { | ||
1317 | info->peer->core_transmit[info->handler_n] = NULL; | ||
1318 | info->peer->infos[info->handler_n] = NULL; | ||
1319 | } | ||
1320 | if (total_size > size) | 1314 | if (total_size > size) |
1321 | { | 1315 | { |
1322 | GNUNET_break (0); | 1316 | /* Retry */ |
1323 | total_size = 0; | 1317 | struct GNUNET_PeerIdentity id; |
1324 | } | 1318 | |
1325 | else | 1319 | GNUNET_PEER_resolve(info->peer->id, &id); |
1326 | { | 1320 | info->peer->infos[info->handler_n] = info; |
1327 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_MULTICAST); | 1321 | info->peer->core_transmit[info->handler_n] = |
1328 | msg->header.size = htons (total_size); | 1322 | GNUNET_CORE_notify_transmit_ready (core_handle, |
1329 | GNUNET_PEER_resolve (info->origin->oid, &msg->oid); | 1323 | 0, |
1330 | msg->tid = htonl (info->origin->tid); | 1324 | 0, |
1331 | memcpy (&msg[1], info->data, total_size); | 1325 | GNUNET_TIME_UNIT_FOREVER_REL, |
1326 | &id, | ||
1327 | total_size, | ||
1328 | &send_core_data_multicast, | ||
1329 | info); | ||
1330 | return 0; | ||
1332 | } | 1331 | } |
1332 | info->peer->core_transmit[info->handler_n] = NULL; | ||
1333 | info->peer->infos[info->handler_n] = NULL; | ||
1334 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_MULTICAST); | ||
1335 | msg->header.size = htons (total_size); | ||
1336 | GNUNET_PEER_resolve (info->origin->oid, &msg->oid); | ||
1337 | msg->tid = htonl (info->origin->tid); | ||
1338 | memcpy (&msg[1], info->data, info->size); | ||
1333 | if (0 == --(*info->copies)) | 1339 | if (0 == --(*info->copies)) |
1334 | { | 1340 | { |
1335 | if (NULL != info->client) | 1341 | if (NULL != info->client) |
1336 | { | 1342 | { |
1343 | /* FIXME One unresponsive neighbor (who doesn't "call" tmt_rdy) can lock | ||
1344 | * the client from sending anything else to the service. | ||
1345 | * - Call receive_done after certain timeout. | ||
1346 | * - Here cancel the timeout. | ||
1347 | */ | ||
1337 | GNUNET_SERVER_receive_done (info->client, GNUNET_OK); | 1348 | GNUNET_SERVER_receive_done (info->client, GNUNET_OK); |
1338 | } | 1349 | } |
1339 | GNUNET_free (info->data); | 1350 | GNUNET_free (info->data); |
@@ -2088,7 +2099,9 @@ dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp, | |||
2088 | enum GNUNET_BLOCK_Type type, size_t size, const void *data) | 2099 | enum GNUNET_BLOCK_Type type, size_t size, const void *data) |
2089 | { | 2100 | { |
2090 | struct MeshPathInfo *path_info = cls; | 2101 | struct MeshPathInfo *path_info = cls; |
2102 | struct MeshPathInfo *path_info_aux; | ||
2091 | struct MeshPeerPath *p; | 2103 | struct MeshPeerPath *p; |
2104 | struct MeshPeerPath *aux; | ||
2092 | struct GNUNET_PeerIdentity pi; | 2105 | struct GNUNET_PeerIdentity pi; |
2093 | int i; | 2106 | int i; |
2094 | 2107 | ||
@@ -2121,6 +2134,36 @@ dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp, | |||
2121 | for (i = 0; i < path_info->peer->ntunnels; i++) | 2134 | for (i = 0; i < path_info->peer->ntunnels; i++) |
2122 | { | 2135 | { |
2123 | tunnel_add_peer (path_info->peer->tunnels[i], path_info->peer); | 2136 | tunnel_add_peer (path_info->peer->tunnels[i], path_info->peer); |
2137 | aux = tree_get_path_to_peer(path_info->peer->tunnels[i]->tree, | ||
2138 | path_info->peer->id); | ||
2139 | if (aux->length > 1) | ||
2140 | { | ||
2141 | struct GNUNET_PeerIdentity id; | ||
2142 | |||
2143 | path_info_aux = GNUNET_malloc (sizeof (struct MeshPathInfo)); | ||
2144 | path_info_aux->path = aux; | ||
2145 | path_info_aux->peer = path_info->peer; | ||
2146 | path_info_aux->t = path_info->t; | ||
2147 | GNUNET_PEER_resolve (p->peers[1], &id); | ||
2148 | GNUNET_CORE_notify_transmit_ready (core_handle, /* handle */ | ||
2149 | 0, /* cork */ | ||
2150 | 0, /* priority */ | ||
2151 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
2152 | /* timeout */ | ||
2153 | &id, /* target */ | ||
2154 | sizeof (struct GNUNET_MESH_ManipulatePath) | ||
2155 | + | ||
2156 | (aux->length * | ||
2157 | sizeof (struct GNUNET_PeerIdentity)), | ||
2158 | /*size */ | ||
2159 | &send_core_create_path, | ||
2160 | /* callback */ | ||
2161 | path_info_aux); /* cls */ | ||
2162 | } | ||
2163 | else | ||
2164 | { | ||
2165 | send_client_peer_connected(path_info->t, myid); | ||
2166 | } | ||
2124 | } | 2167 | } |
2125 | GNUNET_free (path_info); | 2168 | GNUNET_free (path_info); |
2126 | 2169 | ||
@@ -2173,6 +2216,9 @@ dht_get_type_handler (void *cls, struct GNUNET_TIME_Absolute exp, | |||
2173 | if ((NULL == get_path || NULL == put_path) && NULL == peer_info->path_head && | 2216 | if ((NULL == get_path || NULL == put_path) && NULL == peer_info->path_head && |
2174 | NULL == peer_info->dhtget) | 2217 | NULL == peer_info->dhtget) |
2175 | { | 2218 | { |
2219 | path_info = GNUNET_malloc (sizeof (struct MeshPathInfo)); | ||
2220 | path_info->peer = peer_info; | ||
2221 | path_info->t = t; | ||
2176 | /* we don't have a route to the peer, let's try a direct lookup */ | 2222 | /* we don't have a route to the peer, let's try a direct lookup */ |
2177 | peer_info->dhtget = GNUNET_DHT_get_start (dht_handle, | 2223 | peer_info->dhtget = GNUNET_DHT_get_start (dht_handle, |
2178 | /* handle */ | 2224 | /* handle */ |
@@ -2190,7 +2236,8 @@ dht_get_type_handler (void *cls, struct GNUNET_TIME_Absolute exp, | |||
2190 | 0, /* xquery bits */ | 2236 | 0, /* xquery bits */ |
2191 | dht_get_id_handler, | 2237 | dht_get_id_handler, |
2192 | /* callback */ | 2238 | /* callback */ |
2193 | peer_info); /* closure */ | 2239 | path_info); /* closure */ |
2240 | return; | ||
2194 | } | 2241 | } |
2195 | 2242 | ||
2196 | p = path_build_from_dht (get_path, get_path_length, put_path, put_path_length); | 2243 | p = path_build_from_dht (get_path, get_path_length, put_path, put_path_length); |