aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rps/gnunet-service-rps.c93
1 files changed, 62 insertions, 31 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index 3f89f3d86..4acb95b6a 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -1543,52 +1543,83 @@ init_peer_cb (void *cls,
1543} 1543}
1544 1544
1545 1545
1546/** 1546///**
1547 * Callback used to clean the multipeermap. 1547// * Clean the send channel of a peer
1548// */
1549//void
1550//peer_clean (const struct GNUNET_PeerIdentity *peer)
1551//{
1552// struct PeerContext *peer_ctx;
1553// struct GNUNET_CADET_Channel *channel;
1554//
1555// if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (peer_map, peer))
1556// {
1557// peer_ctx = get_peer_ctx (peer_map, peer);
1558// if (NULL != peer_ctx->send_channel)
1559// {
1560// channel = peer_ctx->send_channel;
1561// peer_ctx->send_channel = NULL;
1562// GNUNET_CADET_channel_destroy (channel);
1563// }
1564// }
1565//}
1566
1567
1568/**
1569 * Callback used to remove peers from the multipeermap.
1548 */ 1570 */
1549 int 1571 int
1550peer_remove_cb (void *cls, const struct GNUNET_PeerIdentity *key, void *value) 1572peer_remove_cb (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
1551{ 1573{
1552 struct PeerContext *peer_ctx; 1574 struct PeerContext *peer_ctx;
1553 const struct GNUNET_CADET_Channel *ch = (const struct GNUNET_CADET_Channel *) cls; 1575 const struct GNUNET_CADET_Channel *channel =
1576 (const struct GNUNET_CADET_Channel *) cls;
1554 struct GNUNET_CADET_Channel *recv; 1577 struct GNUNET_CADET_Channel *recv;
1555 struct GNUNET_CADET_Channel *send; 1578 struct GNUNET_CADET_Channel *send;
1556 1579
1557 peer_ctx = (struct PeerContext *) value; 1580 if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (peer_map, value))
1581 {
1582 peer_ctx = (struct PeerContext *) value;
1558 1583
1559 if (0 != peer_ctx->num_outstanding_ops) 1584 if (0 != peer_ctx->num_outstanding_ops)
1560 GNUNET_array_grow (peer_ctx->outstanding_ops, peer_ctx->num_outstanding_ops, 0); 1585 GNUNET_array_grow (peer_ctx->outstanding_ops,
1586 peer_ctx->num_outstanding_ops,
1587 0);
1561 1588
1562 if (NULL != peer_ctx->mq) 1589 if (NULL != peer_ctx->mq)
1563 GNUNET_MQ_destroy (peer_ctx->mq); 1590 GNUNET_MQ_destroy (peer_ctx->mq);
1564 1591
1565 if (NULL != peer_ctx->is_live_task) 1592 if (NULL != peer_ctx->is_live_task)
1566 { 1593 {
1567 GNUNET_CADET_notify_transmit_ready_cancel (peer_ctx->is_live_task); 1594 LOG (GNUNET_ERROR_TYPE_DEBUG,
1568 peer_ctx->is_live_task = NULL; 1595 "Trying to cancle is_live_task for peer %s\n",
1569 } 1596 GNUNET_i2s (key));
1597 GNUNET_CADET_notify_transmit_ready_cancel (peer_ctx->is_live_task);
1598 peer_ctx->is_live_task = NULL;
1599 }
1570 1600
1571 send = peer_ctx->send_channel; 1601 send = peer_ctx->send_channel;
1572 peer_ctx->send_channel = NULL; 1602 peer_ctx->send_channel = NULL;
1573 recv = peer_ctx->send_channel; 1603 recv = peer_ctx->send_channel;
1574 peer_ctx->recv_channel = NULL; 1604 peer_ctx->recv_channel = NULL;
1575 1605
1576 if (NULL != send 1606 if (NULL != send
1577 && ch != send) 1607 && channel != send)
1578 { 1608 {
1579 GNUNET_CADET_channel_destroy (send); 1609 GNUNET_CADET_channel_destroy (send);
1580 } 1610 }
1581 1611
1582 if (NULL != recv 1612 if (NULL != recv
1583 && ch != recv) 1613 && channel != recv)
1584 { 1614 {
1585 GNUNET_CADET_channel_destroy (recv); 1615 GNUNET_CADET_channel_destroy (recv);
1586 } 1616 }
1587 1617
1588 if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_remove_all (peer_map, key)) 1618 if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_remove_all (peer_map, key))
1589 LOG (GNUNET_ERROR_TYPE_WARNING, "removing peer from peer_map failed\n"); 1619 LOG (GNUNET_ERROR_TYPE_WARNING, "removing peer from peer_map failed\n");
1590 else 1620 else
1591 GNUNET_free (peer_ctx); 1621 GNUNET_free (peer_ctx);
1622 }
1592 1623
1593 return GNUNET_YES; 1624 return GNUNET_YES;
1594} 1625}