Displaying 9 results from an estimated 9 matches for "buffer_read_completed".
2019 Jul 30
0
[PATCH libnbd] examples: Fix theoretical cookie race in example.
...a/examples/glib-main-loop.c b/examples/glib-main-loop.c
index 9f98033..826651e 100644
--- a/examples/glib-main-loop.c
+++ b/examples/glib-main-loop.c
@@ -247,6 +247,7 @@ static const char *dest_args[] = {
#define BUFFER_SIZE 65536
enum buffer_state {
+ BUFFER_UNUSED = 0,
BUFFER_READING,
BUFFER_READ_COMPLETED,
BUFFER_WRITING,
@@ -254,13 +255,6 @@ enum buffer_state {
struct buffer {
uint64_t offset;
- /* Note that command cookies are only unique per libnbd handle.
- * Since we have two handles but we must look up completed commands
- * in the buffer table by cookie we must maintain separate...
2019 Jul 30
4
[PATCH libnbd] examples: Fix theoretical cookie race in example.
Previously discussed here:
https://www.redhat.com/archives/libguestfs/2019-July/msg00213.html
It turns out that deferring callbacks is a PITA. (It would be a bit
easier if C has closures.) However by rewriting the example we can
avoid the need to use the cookie at all and make it run a bit more
efficiently, so let's do that instead.
Rich.
2019 Jul 17
1
Re: [PATCH libnbd] examples: Include an example of integrating with the glib main loop.
...ist of buffers waiting to be written. Note that the source
> + * server can answer requests out of order so these buffers may not be
> + * sorted by offset.
> + */
> +#define MAX_BUFFERS 16
> +#define BUFFER_SIZE 65536
> +
> +enum buffer_state {
> + BUFFER_READING,
> + BUFFER_READ_COMPLETED,
> + BUFFER_WRITING,
> +};
> +
> +struct buffer {
> + uint64_t offset;
> + int64_t cookie;
> + enum buffer_state state;
> + char *data;
> +};
> +
> +static struct buffer buffers[MAX_BUFFERS];
> +static size_t nr_buffers;
> +
> +static bool finished, re...
2019 Jul 15
2
[PATCH libnbd] examples: Include an example of integrating with the glibc main loop.
** NOT WORKING **
This patch shows how to integrate libnbd and the glib main loop.
Posted mainly as a point of discussion as it doesn't quite work yet.
Rich.
2019 Jul 15
0
[PATCH libnbd] examples: Include an example of integrating with the glib main loop.
...t;, "size=1G", NULL
+};
+
+/* The list of buffers waiting to be written. Note that the source
+ * server can answer requests out of order so these buffers may not be
+ * sorted by offset.
+ */
+#define MAX_BUFFERS 16
+#define BUFFER_SIZE 65536
+
+enum buffer_state {
+ BUFFER_READING,
+ BUFFER_READ_COMPLETED,
+ BUFFER_WRITING,
+};
+
+struct buffer {
+ uint64_t offset;
+ int64_t cookie;
+ enum buffer_state state;
+ char *data;
+};
+
+static struct buffer buffers[MAX_BUFFERS];
+static size_t nr_buffers;
+
+static bool finished, reader_paused;
+
+static GMainLoop *loop;
+
+static void connected (stru...
2019 Jul 17
0
[PATCH libnbd v2] examples: Include an example of integrating with the glib main loop.
...t;, "size=1G", NULL
+};
+
+/* The list of buffers waiting to be written. Note that the source
+ * server can answer requests out of order so these buffers may not be
+ * sorted by offset.
+ */
+#define MAX_BUFFERS 16
+#define BUFFER_SIZE 65536
+
+enum buffer_state {
+ BUFFER_READING,
+ BUFFER_READ_COMPLETED,
+ BUFFER_WRITING,
+};
+
+struct buffer {
+ uint64_t offset;
+ /* Note that command cookies are only unique per libnbd handle.
+ * Since we have two handles but we must look up completed commands
+ * in the buffer table by cookie we must maintain separate read and
+ * write cookies.
+ */...
2019 Jul 17
2
[PATCH libnbd v2] examples: Include an example of integrating with glib main loop.
This is working now, and incorporates all of the changes in Eric's
review, *except* that it still doesn't retire commands (although this
seems to make no obvious difference, except possibly a performance and
memory impact).
Rich.
2019 Aug 13
0
[PATCH libnbd] api: Rename nbd_aio_*_callback to nbd_aio_*.
...ata,
+ BUFFER_SIZE, buffers[i].offset,
+ finished_read, &buffers[i], 0) == -1) {
fprintf (stderr, "%s\n", nbd_get_error ());
exit (EXIT_FAILURE);
}
@@ -426,9 +426,9 @@ write_data (gpointer user_data)
assert (buffer->state == BUFFER_READ_COMPLETED);
buffer->state = BUFFER_WRITING;
- if (nbd_aio_pwrite_callback (gsdest->nbd, buffer->data,
- BUFFER_SIZE, buffer->offset,
- finished_write, buffer, 0) == -1) {
+ if (nbd_aio_pwrite (gsdest->nbd, buffer->data,
+...
2019 Aug 13
2
[PATCH libnbd] api: Rename nbd_aio_*_callback to nbd_aio_*.
This applies on top of the OClosure v2 series posted a few
minutes ago.
Rich.