diff options
author | Alessio Vanni <vannilla@firemail.cc> | 2020-05-14 16:03:10 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-05-19 02:41:47 +0200 |
commit | f4771fcc1c3fda21a46d0cb85d8b29e012254696 (patch) | |
tree | 012df74ed2cf44cb20605b239e1b88dab6edc645 /src/testbed | |
parent | 6a52ce5f9bc35a852b215e7073f3a0d2665ca8de (diff) | |
download | gnunet-f4771fcc1c3fda21a46d0cb85d8b29e012254696.tar.gz gnunet-f4771fcc1c3fda21a46d0cb85d8b29e012254696.zip |
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 <christian@grothoff.org>
Diffstat (limited to 'src/testbed')
-rw-r--r-- | src/testbed/gnunet-service-testbed_cpustatus.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/testbed/gnunet-service-testbed_cpustatus.c b/src/testbed/gnunet-service-testbed_cpustatus.c index e96449def..2d490ba8c 100644 --- a/src/testbed/gnunet-service-testbed_cpustatus.c +++ b/src/testbed/gnunet-service-testbed_cpustatus.c | |||
@@ -568,7 +568,7 @@ sample_load_task (void *cls) | |||
568 | ld_cpu, ld_disk, mem_usage, nproc); | 568 | ld_cpu, ld_disk, mem_usage, nproc); |
569 | if (0 < nbs) | 569 | if (0 < nbs) |
570 | { | 570 | { |
571 | GNUNET_BIO_write (bw, str, nbs); | 571 | GNUNET_BIO_write (bw, "sample load task", str, nbs); |
572 | } | 572 | } |
573 | else | 573 | else |
574 | GNUNET_break (0); | 574 | GNUNET_break (0); |
@@ -612,7 +612,7 @@ GST_stats_init (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
612 | hostname, (intmax_t) getpid ()); | 612 | hostname, (intmax_t) getpid ()); |
613 | GNUNET_free (stats_dir); | 613 | GNUNET_free (stats_dir); |
614 | GNUNET_free (hostname); | 614 | GNUNET_free (hostname); |
615 | if (NULL == (bw = GNUNET_BIO_write_open (fn))) | 615 | if (NULL == (bw = GNUNET_BIO_write_open_file (fn))) |
616 | { | 616 | { |
617 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 617 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
618 | _ ("Cannot open %s for writing load statistics. " | 618 | _ ("Cannot open %s for writing load statistics. " |
@@ -656,7 +656,7 @@ GST_stats_destroy () | |||
656 | GNUNET_SCHEDULER_cancel (sample_load_task_id); | 656 | GNUNET_SCHEDULER_cancel (sample_load_task_id); |
657 | sample_load_task_id = NULL; | 657 | sample_load_task_id = NULL; |
658 | } | 658 | } |
659 | GNUNET_break (GNUNET_OK == GNUNET_BIO_write_close (bw)); | 659 | GNUNET_break (GNUNET_OK == GNUNET_BIO_write_close (bw, NULL)); |
660 | bw = NULL; | 660 | bw = NULL; |
661 | } | 661 | } |
662 | 662 | ||