[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] 03/06: News: Introduced closure to hold store context when cali
From: |
gnunet |
Subject: |
[gnunet] 03/06: News: Introduced closure to hold store context when caling function to add hello in peerstore. |
Date: |
Fri, 27 Oct 2023 17:43:56 +0200 |
This is an automated email from the git hooks/post-receive script.
t3sserakt pushed a commit to branch master
in repository gnunet.
commit 21be8873788b1b5a725ec78116d3c0cde5e0b6cb
Author: t3sserakt <t3ss@posteo.de>
AuthorDate: Fri Oct 27 11:33:37 2023 +0200
News: Introduced closure to hold store context when caling function to add
hello in peerstore.
---
src/include/gnunet_peerstore_service.h | 10 ++++++++++
src/service/hostlist/gnunet-daemon-hostlist_client.c | 13 ++++++++++---
src/service/topology/gnunet-daemon-topology.c | 13 ++++++++++---
3 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/src/include/gnunet_peerstore_service.h
b/src/include/gnunet_peerstore_service.h
index 99ba98593..c57a66b1f 100644
--- a/src/include/gnunet_peerstore_service.h
+++ b/src/include/gnunet_peerstore_service.h
@@ -234,6 +234,16 @@ struct GNUNET_PEERSTORE_StoreHelloContext
int success;
};
+/**
+ * Closure to hold a GNUNET_PEERSTORE_StoreHelloContext.
+ */
+struct GNUNET_PEERSTORE_StoreHelloContextClosure
+{
+ /**
+ * The GNUNET_PEERSTORE_StoreHelloContext to hold.
+ */
+ struct GNUNET_PEERSTORE_StoreHelloContext *shc;
+};
/**
* Function called by PEERSTORE for each matching record.
diff --git a/src/service/hostlist/gnunet-daemon-hostlist_client.c
b/src/service/hostlist/gnunet-daemon-hostlist_client.c
index 483233fc6..75b497d14 100644
--- a/src/service/hostlist/gnunet-daemon-hostlist_client.c
+++ b/src/service/hostlist/gnunet-daemon-hostlist_client.c
@@ -323,7 +323,7 @@ static struct GNUNET_PEERSTORE_Handle *peerstore;
static void
shc_cont (void *cls, int success)
{
- (void *) cls;
+ struct GNUNET_PEERSTORE_StoreHelloContextClosure *shc_cls = cls;
if (GNUNET_YES == success)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -331,6 +331,7 @@ shc_cont (void *cls, int success)
else
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Error storing hostlist entry!\n");
+ GNUNET_CONTAINER_DLL_remove (shc_head, shc_tail, shc_cls->shc);
}
@@ -348,6 +349,7 @@ callback_download (void *ptr, size_t size, size_t nmemb,
void *ctx)
{
static char download_buffer[GNUNET_MAX_MESSAGE_SIZE - 1];
struct GNUNET_PEERSTORE_StoreHelloContext *shc;
+ struct GNUNET_PEERSTORE_StoreHelloContextClosure *shc_cls;
const char *cbuf = ptr;
const struct GNUNET_MessageHeader *msg;
size_t total;
@@ -411,11 +413,16 @@ callback_download (void *ptr, size_t size, size_t nmemb,
void *ctx)
1,
GNUNET_NO);
stat_hellos_obtained++;
+ shc_cls = GNUNET_new (struct GNUNET_PEERSTORE_StoreHelloContextClosure);
shc = GNUNET_PEERSTORE_hello_add (peerstore,
msg,
shc_cont,
- NULL);
- GNUNET_CONTAINER_DLL_insert (shc_head, shc_tail, shc);
+ shc_cls);
+ if (NULL != shc)
+ {
+ shc_cls->shc = shc;
+ GNUNET_CONTAINER_DLL_insert (shc_head, shc_tail, shc);
+ }
memmove (download_buffer, &download_buffer[msize], download_pos - msize);
download_pos -= msize;
}
diff --git a/src/service/topology/gnunet-daemon-topology.c
b/src/service/topology/gnunet-daemon-topology.c
index 0f4b046f8..19bd29563 100644
--- a/src/service/topology/gnunet-daemon-topology.c
+++ b/src/service/topology/gnunet-daemon-topology.c
@@ -843,7 +843,7 @@ check_hello (void *cls, const struct GNUNET_MessageHeader
*message)
static void
shc_cont (void *cls, int success)
{
- (void *) cls;
+ struct GNUNET_PEERSTORE_StoreHelloContextClosure *shc_cls = cls;
if (GNUNET_YES == success)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -851,6 +851,7 @@ shc_cont (void *cls, int success)
else
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Error storing hello!\n");
+ GNUNET_CONTAINER_DLL_remove (shc_head, shc_tail, shc_cls->shc);
}
@@ -865,6 +866,7 @@ static void
handle_hello (void *cls, const struct GNUNET_MessageHeader *message)
{
struct GNUNET_PEERSTORE_StoreHelloContext *shc;
+ struct GNUNET_PEERSTORE_StoreHelloContextClosure *shc_cls;
const struct GNUNET_PeerIdentity *other = cls;
struct GNUNET_HELLO_Builder *builder = GNUNET_HELLO_builder_from_msg (
message);
@@ -877,8 +879,13 @@ handle_hello (void *cls, const struct GNUNET_MessageHeader
*message)
1,
GNUNET_NO);
GNUNET_HELLO_builder_from_msg (message);
- shc = GNUNET_PEERSTORE_hello_add (ps, message, &shc_cont, NULL);
- GNUNET_CONTAINER_DLL_insert (shc_head, shc_tail, shc);
+ shc_cls = GNUNET_new (struct GNUNET_PEERSTORE_StoreHelloContextClosure);
+ shc = GNUNET_PEERSTORE_hello_add (ps, message, &shc_cont, shc_cls);
+ if (NULL != shc)
+ {
+ shc_cls->shc = shc;
+ GNUNET_CONTAINER_DLL_insert (shc_head, shc_tail, shc);
+ }
GNUNET_HELLO_builder_free (builder);
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [gnunet] branch master updated (99118ccc8 -> 23853f2d7), gnunet, 2023/10/27
- [gnunet] 01/06: Changed relative path to no force test config, gnunet, 2023/10/27
- [gnunet] 02/06: TNG: Fixed bug in handling hello to start validation., gnunet, 2023/10/27
- [gnunet] 05/06: Cadet: Changes to use DhtHelloMessage instead of HelloUriMessage, and to hand over not a HelloMessage, but a block to the dht., gnunet, 2023/10/27
- [gnunet] 04/06: Hello: Fixed usage of GNUNET_HELLO_builder_iterate., gnunet, 2023/10/27
- [gnunet] 06/06: Merge branch 'master' of ssh://git.gnunet.org/gnunet, gnunet, 2023/10/27
- [gnunet] 03/06: News: Introduced closure to hold store context when caling function to add hello in peerstore.,
gnunet <=