From f4771fcc1c3fda21a46d0cb85d8b29e012254696 Mon Sep 17 00:00:00 2001 From: Alessio Vanni Date: Thu, 14 May 2020 16:03:10 +0200 Subject: Improved BIO API BIO now supports reading from and writing to in-memory buffers. For reading, an allocated buffer (array) and a size is passed as arguments to the function opening the handle. For writing, a GNUNET_Buffer is created and used internally. The buffer contents can be extracted using the relevant function. There is a new API in addition to the existing read/write: this new API is more "declarative" in nature and is meant to mimic APIs like GNUNET_SQ. The read/write operations are defined in an array of specs which are then "commited" in a single (non-atomic) operation, rather than explicitly executing multiple function calls and checking their return value. Also there are small changes to GNUNET_Buffer to account for BIO's new features. Signed-off-by: Christian Grothoff --- src/nse/gnunet-service-nse.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nse') diff --git a/src/nse/gnunet-service-nse.c b/src/nse/gnunet-service-nse.c index 793f60694..411f533a5 100644 --- a/src/nse/gnunet-service-nse.c +++ b/src/nse/gnunet-service-nse.c @@ -1001,7 +1001,7 @@ handle_p2p_estimate (void *cls, if (NULL != lh) GNUNET_TESTBED_LOGGER_write (lh, &t, sizeof(uint64_t)); if (NULL != histogram) - GNUNET_BIO_write_int64 (histogram, t); + GNUNET_BIO_write_int64 (histogram, "histogram-time", t); } #endif GNUNET_STATISTICS_update (stats, "# flood messages received", 1, GNUNET_NO); @@ -1299,7 +1299,7 @@ shutdown_task (void *cls) } if (NULL != histogram) { - GNUNET_BIO_write_close (histogram); + GNUNET_BIO_write_close (histogram, NULL); histogram = NULL; } #endif @@ -1453,7 +1453,7 @@ run (void *cls, GNUNET_assert ( 0 < GNUNET_asprintf (&histogram_fn, "%s/timestamps", histogram_dir)); GNUNET_free (histogram_dir); - histogram = GNUNET_BIO_write_open (histogram_fn); + histogram = GNUNET_BIO_write_open_file (histogram_fn); if (NULL == histogram) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unable to open histogram file `%s'\n", -- cgit v1.2.3