aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheJackiMonster <thejackimonster@gmail.com>2024-02-19 15:24:52 +0100
committerTheJackiMonster <thejackimonster@gmail.com>2024-02-19 15:24:52 +0100
commite574399beb219aa9465ed23f36b494bc4e332fcd (patch)
tree1637bbda6c4525f489e1359816c04589be982d8d
parentfb03d6b34acca5b2f84347475ef380ebe3616988 (diff)
downloadgnunet-e574399beb219aa9465ed23f36b494bc4e332fcd.tar.gz
gnunet-e574399beb219aa9465ed23f36b494bc4e332fcd.zip
MESSENGER: Cleanup circular dependency in linked deletion
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-rw-r--r--src/service/messenger/messenger_api_room.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/service/messenger/messenger_api_room.c b/src/service/messenger/messenger_api_room.c
index 5a9c719f8..715934f1c 100644
--- a/src/service/messenger/messenger_api_room.c
+++ b/src/service/messenger/messenger_api_room.c
@@ -831,6 +831,22 @@ struct GNUNET_MESSENGER_RoomLinkDeletionInfo
831 831
832 832
833static enum GNUNET_GenericReturnValue 833static enum GNUNET_GenericReturnValue
834clear_linked_hash (void *cls,
835 const struct GNUNET_HashCode *key,
836 void *value)
837{
838 struct GNUNET_HashCode **linked = cls;
839 struct GNUNET_HashCode *hash = value;
840
841 if (0 != GNUNET_CRYPTO_hash_cmp (*linked, hash))
842 return GNUNET_YES;
843
844 *linked = hash;
845 return GNUNET_NO;
846}
847
848
849static enum GNUNET_GenericReturnValue
834delete_linked_hash (void *cls, 850delete_linked_hash (void *cls,
835 const struct GNUNET_HashCode *key, 851 const struct GNUNET_HashCode *key,
836 void *value) 852 void *value)
@@ -838,6 +854,19 @@ delete_linked_hash (void *cls,
838 struct GNUNET_MESSENGER_RoomLinkDeletionInfo *info = cls; 854 struct GNUNET_MESSENGER_RoomLinkDeletionInfo *info = cls;
839 struct GNUNET_HashCode *hash = value; 855 struct GNUNET_HashCode *hash = value;
840 856
857 struct GNUNET_HashCode key_value;
858 GNUNET_memcpy (&key_value, key, sizeof (key_value));
859
860 struct GNUNET_HashCode *linked = &key_value;
861
862 GNUNET_CONTAINER_multihashmap_get_multiple (info->room->links, hash,
863 clear_linked_hash, &linked);
864
865 if ((linked != &key_value) &&
866 (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove (info->room->links,
867 hash, linked)))
868 GNUNET_free (linked);
869
841 if (info->deletion) 870 if (info->deletion)
842 info->deletion (info->room, hash, info->delay); 871 info->deletion (info->room, hash, info->delay);
843 872