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-logger | |
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-logger')
-rw-r--r-- | src/testbed-logger/gnunet-service-testbed-logger.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/testbed-logger/gnunet-service-testbed-logger.c b/src/testbed-logger/gnunet-service-testbed-logger.c index 4e0a3cd34..81652fa4f 100644 --- a/src/testbed-logger/gnunet-service-testbed-logger.c +++ b/src/testbed-logger/gnunet-service-testbed-logger.c | |||
@@ -85,6 +85,7 @@ handle_log_msg (void *cls, | |||
85 | 85 | ||
86 | ms = ntohs (msg->size) - sizeof(struct GNUNET_MessageHeader); | 86 | ms = ntohs (msg->size) - sizeof(struct GNUNET_MessageHeader); |
87 | GNUNET_BIO_write (bio, | 87 | GNUNET_BIO_write (bio, |
88 | "testbed-logger-handle-log-msg", | ||
88 | &msg[1], | 89 | &msg[1], |
89 | ms); | 90 | ms); |
90 | GNUNET_SERVICE_client_continue (client); | 91 | GNUNET_SERVICE_client_continue (client); |
@@ -108,7 +109,7 @@ shutdown_task (void *cls) | |||
108 | return; | 109 | return; |
109 | } | 110 | } |
110 | GNUNET_break (GNUNET_OK == | 111 | GNUNET_break (GNUNET_OK == |
111 | GNUNET_BIO_write_close (bio)); | 112 | GNUNET_BIO_write_close (bio, NULL)); |
112 | } | 113 | } |
113 | 114 | ||
114 | 115 | ||
@@ -202,7 +203,7 @@ logger_run (void *cls, | |||
202 | (intmax_t) pid); | 203 | (intmax_t) pid); |
203 | GNUNET_free (hname); | 204 | GNUNET_free (hname); |
204 | GNUNET_free (dir); | 205 | GNUNET_free (dir); |
205 | if (NULL == (bio = GNUNET_BIO_write_open (fn))) | 206 | if (NULL == (bio = GNUNET_BIO_write_open_file (fn))) |
206 | { | 207 | { |
207 | GNUNET_free (fn); | 208 | GNUNET_free (fn); |
208 | GNUNET_SCHEDULER_shutdown (); | 209 | GNUNET_SCHEDULER_shutdown (); |