diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-10-10 15:15:25 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-10-10 15:15:25 +0000 |
commit | f02bdf449974e76388e1fd5dff03f6c4e6bc39fd (patch) | |
tree | caacc09300f6cabdaa8316a12bbd1c396cf51f04 /src/mesh/gnunet-service-mesh_peer.c | |
parent | dd3a1c05284929dabcafab2a79c872b29d162e39 (diff) | |
download | gnunet-f02bdf449974e76388e1fd5dff03f6c4e6bc39fd.tar.gz gnunet-f02bdf449974e76388e1fd5dff03f6c4e6bc39fd.zip |
- fixes
Diffstat (limited to 'src/mesh/gnunet-service-mesh_peer.c')
-rw-r--r-- | src/mesh/gnunet-service-mesh_peer.c | 94 |
1 files changed, 73 insertions, 21 deletions
diff --git a/src/mesh/gnunet-service-mesh_peer.c b/src/mesh/gnunet-service-mesh_peer.c index 48d5eda7c..42717b8eb 100644 --- a/src/mesh/gnunet-service-mesh_peer.c +++ b/src/mesh/gnunet-service-mesh_peer.c | |||
@@ -1002,7 +1002,7 @@ queue_send (void *cls, size_t size, void *buf) | |||
1002 | if (GNUNET_YES == t->destroy && 0 == t->pending_messages) | 1002 | if (GNUNET_YES == t->destroy && 0 == t->pending_messages) |
1003 | { | 1003 | { |
1004 | // LOG (GNUNET_ERROR_TYPE_DEBUG, "* destroying tunnel!\n"); | 1004 | // LOG (GNUNET_ERROR_TYPE_DEBUG, "* destroying tunnel!\n"); |
1005 | tunnel_destroy (t); | 1005 | GMT_destroy (t); |
1006 | } | 1006 | } |
1007 | } | 1007 | } |
1008 | LOG (GNUNET_ERROR_TYPE_DEBUG, "* Return %d\n", data_size); | 1008 | LOG (GNUNET_ERROR_TYPE_DEBUG, "* Return %d\n", data_size); |
@@ -1010,6 +1010,22 @@ queue_send (void *cls, size_t size, void *buf) | |||
1010 | } | 1010 | } |
1011 | 1011 | ||
1012 | 1012 | ||
1013 | static int | ||
1014 | queue_is_sendable (struct MeshPeerQueue *q) | ||
1015 | { | ||
1016 | /* Is PID-independent? */ | ||
1017 | switch (q->type) | ||
1018 | { | ||
1019 | case GNUNET_MESSAGE_TYPE_MESH_ACK: | ||
1020 | case GNUNET_MESSAGE_TYPE_MESH_POLL: | ||
1021 | return GNUNET_YES; | ||
1022 | } | ||
1023 | |||
1024 | if (GMC_is_sendable (q->c, q->fwd)) | ||
1025 | return GNUNET_YES; | ||
1026 | |||
1027 | return GNUNET_NO; | ||
1028 | } | ||
1013 | 1029 | ||
1014 | /** | 1030 | /** |
1015 | * Get first sendable message. | 1031 | * Get first sendable message. |
@@ -1033,26 +1049,6 @@ peer_get_first_message (const struct MeshPeer *peer) | |||
1033 | } | 1049 | } |
1034 | 1050 | ||
1035 | 1051 | ||
1036 | static int | ||
1037 | queue_is_sendable (struct MeshPeerQueue *q) | ||
1038 | { | ||
1039 | struct MeshFlowControl *fc; | ||
1040 | |||
1041 | /* Is PID-independent? */ | ||
1042 | switch (q->type) | ||
1043 | { | ||
1044 | case GNUNET_MESSAGE_TYPE_MESH_ACK: | ||
1045 | case GNUNET_MESSAGE_TYPE_MESH_POLL: | ||
1046 | return GNUNET_YES; | ||
1047 | } | ||
1048 | |||
1049 | /* Is PID allowed? */ | ||
1050 | fc = q->fwd ? &q->c->fwd_fc : &q->c->bck_fc; | ||
1051 | if (GMC_is_pid_bigger (fc->last_ack_recv, fc->last_pid_sent)) | ||
1052 | return GNUNET_YES; | ||
1053 | |||
1054 | return GNUNET_NO; | ||
1055 | } | ||
1056 | 1052 | ||
1057 | 1053 | ||
1058 | /******************************************************************************/ | 1054 | /******************************************************************************/ |
@@ -1314,6 +1310,62 @@ GMP_queue_cancel (struct MeshPeer *peer, struct MeshConnection *c) | |||
1314 | 1310 | ||
1315 | 1311 | ||
1316 | /** | 1312 | /** |
1313 | * Get the first transmittable message for a connection. | ||
1314 | * | ||
1315 | * @param peer Neighboring peer. | ||
1316 | * @param c Connection. | ||
1317 | * | ||
1318 | * @return First transmittable message. | ||
1319 | */ | ||
1320 | static struct MeshPeerQueue * | ||
1321 | connection_get_first_message (struct MeshPeer *peer, struct MeshConnection *c) | ||
1322 | { | ||
1323 | struct MeshPeerQueue *q; | ||
1324 | |||
1325 | for (q = peer->queue_head; NULL != q; q = q->next) | ||
1326 | { | ||
1327 | if (q->c != c) | ||
1328 | continue; | ||
1329 | if (queue_is_sendable (q)) | ||
1330 | return q; | ||
1331 | } | ||
1332 | |||
1333 | return NULL; | ||
1334 | } | ||
1335 | |||
1336 | void | ||
1337 | GMP_queue_unlock (struct MeshPeer *peer, struct MeshConnection *c) | ||
1338 | { | ||
1339 | struct MeshPeerQueue *q; | ||
1340 | size_t size; | ||
1341 | |||
1342 | if (NULL != peer->core_transmit) | ||
1343 | { | ||
1344 | LOG (GNUNET_ERROR_TYPE_DEBUG, " already unlocked!\n"); | ||
1345 | return; /* Already unlocked */ | ||
1346 | } | ||
1347 | |||
1348 | q = connection_get_first_message (c); | ||
1349 | if (NULL == q) | ||
1350 | { | ||
1351 | LOG (GNUNET_ERROR_TYPE_DEBUG, " queue empty!\n"); | ||
1352 | return; /* Nothing to transmit */ | ||
1353 | } | ||
1354 | |||
1355 | size = q->size; | ||
1356 | peer->core_transmit = | ||
1357 | GNUNET_CORE_notify_transmit_ready (core_handle, | ||
1358 | GNUNET_NO, | ||
1359 | 0, | ||
1360 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
1361 | GNUNET_PEER_resolve2 (peer->id), | ||
1362 | size, | ||
1363 | &queue_send, | ||
1364 | peer); | ||
1365 | } | ||
1366 | |||
1367 | |||
1368 | /** | ||
1317 | * Initialize the peer subsystem. | 1369 | * Initialize the peer subsystem. |
1318 | * | 1370 | * |
1319 | * @param c Configuration. | 1371 | * @param c Configuration. |