search for: gssrc

Displaying 20 results from an estimated 24 matches for "gssrc".

Did you mean: ssrc
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 17
1
Re: [PATCH libnbd] examples: Include an example of integrating with the glib main loop.
...--*/ > + > +/* The rest of this file is an example showing how to use the GSource > + * defined above to control two nbdkit subprocesses, copying from one > + * to the other in parallel. > + */ > + > +/* Source and destination nbdkit instances. */ > +static struct NBDSource *gssrc, *gsdest; > + > +#define SIZE (1024*1024*1024) > + > +static const char *src_args[] = { > + "nbdkit", "-s", "-r", "pattern", "size=1G", NULL > +}; > + > +static const char *dest_args[] = { > + "nbdkit", "-...
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 Jul 15
0
[PATCH libnbd] examples: Include an example of integrating with the glib main loop.
...------------------------------------------*/ + +/* The rest of this file is an example showing how to use the GSource + * defined above to control two nbdkit subprocesses, copying from one + * to the other in parallel. + */ + +/* Source and destination nbdkit instances. */ +static struct NBDSource *gssrc, *gsdest; + +#define SIZE (1024*1024*1024) + +static const char *src_args[] = { + "nbdkit", "-s", "-r", "pattern", "size=1G", NULL +}; + +static const char *dest_args[] = { + "nbdkit", "-s", "memory", "size=1G&qu...
2019 Jul 17
0
[PATCH libnbd v2] examples: Include an example of integrating with the glib main loop.
...------------------------------------------*/ + +/* The rest of this file is an example showing how to use the GSource + * defined above to control two nbdkit subprocesses, copying from one + * to the other in parallel. + */ + +/* Source and destination nbdkit instances. */ +static struct NBDSource *gssrc, *gsdest; + +#define SIZE (1024*1024*1024) + +static const char *src_args[] = { + "nbdkit", "-s", "--exit-with-parent", "-r", "pattern", "size=1G", NULL +}; + +static const char *dest_args[] = { + "nbdkit", "-s", &quo...
2019 Jul 30
0
[PATCH libnbd] examples: Fix theoretical cookie race in example.
...ust maintain separate read and - * write cookies. - */ - int64_t rcookie; - int64_t wcookie; enum buffer_state state; char *data; }; @@ -355,7 +349,7 @@ static gboolean read_data (gpointer user_data) { static uint64_t posn = 0; - const size_t i = nr_buffers; + size_t i; if (gssrc == NULL) return FALSE; @@ -367,16 +361,21 @@ read_data (gpointer user_data) return FALSE; } + /* Find a free buffer. */ + for (i = 0; i < MAX_BUFFERS; ++i) + if (buffers[i].state == BUFFER_UNUSED) + goto found; + /* If too many read requests are in flight, return FALS...
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
2
Re: [PATCH libnbd v2] examples: Include an example of integrating with the glib main loop.
...ay still be a possible race: > +/* This idle callback reads data from the source nbdkit until the ring > + * is full. > + */ > +static gboolean > +read_data (gpointer user_data) > +{ > + static uint64_t posn = 0; > + buffers[i].rcookie = > + nbd_aio_pread_callback (gssrc->nbd, buffers[i].data, > + BUFFER_SIZE, buffers[i].offset, > + finished_read, NULL, 0); It may be possible in rare situations that the libnbd state machine can send() the command AND see data ready to recv() (perhaps from a previous co...
2019 Jul 17
0
Re: [PATCH libnbd v2] examples: Include an example of integrating with the glib main loop.
...okie will still be unset at the time > the callback fires... > >> +/* This callback is called from libnbd when any read command finishes. */ >> +static int >> +finished_read (void *vp, int64_t rcookie, int *error) >> +{ >> + size_t i; >> + >> + if (gssrc == NULL) >> + return 0; >> + >> + DEBUG (gssrc, "finished_read: read completed"); >> + >> + /* Find the corresponding buffer and mark it as completed. */ >> + for (i = 0; i < nr_buffers; ++i) { >> + if (buffers[i].rcookie == rcookie) &...
2019 Aug 14
2
Re: [PATCH libnbd 1/4] api: Combine callback and user_data into a single struct.
...NBD_NULL_CALLBACK(completion), 0); A bit more verbose, but the macro cuts it down from something even longer to type. I can live with this conversion. > +++ b/examples/glib-main-loop.c > @@ -384,7 +384,8 @@ read_data (gpointer user_data) > > if (nbd_aio_pread (gssrc->nbd, buffers[i].data, > BUFFER_SIZE, buffers[i].offset, > - finished_read, &buffers[i], 0) == -1) { > + (nbd_completion_callback) { .callback = finished_read, .user_data = &buffers[i] }, > + 0)...
2019 Aug 14
0
Re: [PATCH libnbd 1/4] api: Combine callback and user_data into a single struct.
...n live with this conversion. I was trying to write a generic macro (ie. just ‘NBD_NULL_CALLBACK’) for this, but I don't believe it's possible. > > +++ b/examples/glib-main-loop.c > > @@ -384,7 +384,8 @@ read_data (gpointer user_data) > > > > if (nbd_aio_pread (gssrc->nbd, buffers[i].data, > > BUFFER_SIZE, buffers[i].offset, > > - finished_read, &buffers[i], 0) == -1) { > > + (nbd_completion_callback) { .callback = finished_read, .user_data = &buffers[i] }, > > +...
2019 Aug 13
0
[PATCH libnbd] api: Rename nbd_aio_*_callback to nbd_aio_*.
...goto error; diff --git a/examples/glib-main-loop.c b/examples/glib-main-loop.c index 05a59e3..7b4d215 100644 --- a/examples/glib-main-loop.c +++ b/examples/glib-main-loop.c @@ -382,9 +382,9 @@ read_data (gpointer user_data) nr_buffers++; posn += BUFFER_SIZE; - if (nbd_aio_pread_callback (gssrc->nbd, buffers[i].data, - BUFFER_SIZE, buffers[i].offset, - finished_read, &buffers[i], 0) == -1) { + if (nbd_aio_pread (gssrc->nbd, buffers[i].data, + BUFFER_SIZE, buffers[i].offset, + finis...
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.
2019 Aug 12
0
[PATCH libnbd 7/7] api: Remove the valid_flag from all callbacks.
...ta) /* This callback is called from libnbd when any read command finishes. */ static int -finished_read (unsigned valid_flag, void *vp, int *error) +finished_read (void *vp, int *error) { struct buffer *buffer = vp; - if (!(valid_flag & LIBNBD_CALLBACK_VALID)) - return 0; - if (gssrc == NULL) return 0; @@ -442,13 +439,10 @@ write_data (gpointer user_data) /* This callback is called from libnbd when any write command finishes. */ static int -finished_write (unsigned valid_flag, void *vp, int *error) +finished_write (void *vp, int *error) { struct buffer *buffer =...
2019 Aug 13
8
[PATCH libnbd 0/4] Add free function to callbacks.
Patches 1 & 2 are rather complex, but the end result is that we pass closures + user_data + free function in single struct parameters as I described previously in this email: https://www.redhat.com/archives/libguestfs/2019-August/msg00210.html Patch 3 adds a convenient FREE_CALLBACK macro which seems a worthwhile simplification if you buy into 1 & 2. Patch 4 adds another macro which is
2019 Jul 24
0
[PATCH libnbd 2/3] lib: Implement closure lifetimes.
...his callback is called from libnbd when any read command finishes. */ static int -finished_read (void *vp, int64_t rcookie, int *error) +finished_read (int valid_flag, void *vp, int64_t rcookie, int *error) { size_t i; + if (!(valid_flag & LIBNBD_CALLBACK_VALID)) + return 0; + if (gssrc == NULL) return 0; @@ -460,10 +465,13 @@ write_data (gpointer user_data) /* This callback is called from libnbd when any write command finishes. */ static int -finished_write (void *vp, int64_t wcookie, int *error) +finished_write (int valid_flag, void *vp, int64_t wcookie, int *error)...
2019 Aug 13
0
[PATCH libnbd 2/4] api: Add free function and remove valid_flag parameter.
...ta) /* This callback is called from libnbd when any read command finishes. */ static int -finished_read (unsigned valid_flag, void *vp, int *error) +finished_read (void *vp, int *error) { struct buffer *buffer = vp; - if (!(valid_flag & LIBNBD_CALLBACK_VALID)) - return 0; - if (gssrc == NULL) return 0; @@ -444,13 +441,10 @@ write_data (gpointer user_data) /* This callback is called from libnbd when any write command finishes. */ static int -finished_write (unsigned valid_flag, void *vp, int *error) +finished_write (void *vp, int *error) { struct buffer *buffer =...
2019 Jul 24
0
[PATCH libnbd v2 2/5] lib: Implement closure lifetimes.
...allback is called from libnbd when any read command finishes. */ static int -finished_read (void *vp, int64_t rcookie, int *error) +finished_read (unsigned valid_flag, void *vp, int64_t rcookie, int *error) { size_t i; + if (!(valid_flag & LIBNBD_CALLBACK_VALID)) + return 0; + if (gssrc == NULL) return 0; @@ -460,10 +465,13 @@ write_data (gpointer user_data) /* This callback is called from libnbd when any write command finishes. */ static int -finished_write (void *vp, int64_t wcookie, int *error) +finished_write (unsigned valid_flag, void *vp, int64_t wcookie, int *err...
2019 Aug 13
0
[PATCH libnbd 1/4] api: Combine callback and user_data into a single struct.
...(stderr, "%s\n", nbd_get_error ()); goto error; diff --git a/examples/glib-main-loop.c b/examples/glib-main-loop.c index 7b4d215..a8e8ceb 100644 --- a/examples/glib-main-loop.c +++ b/examples/glib-main-loop.c @@ -384,7 +384,8 @@ read_data (gpointer user_data) if (nbd_aio_pread (gssrc->nbd, buffers[i].data, BUFFER_SIZE, buffers[i].offset, - finished_read, &buffers[i], 0) == -1) { + (nbd_completion_callback) { .callback = finished_read, .user_data = &buffers[i] }, + 0) == -1) { fprin...
2019 Jul 25
0
[PATCH libnbd v3 1/2] lib: Implement closure lifetimes.
...allback is called from libnbd when any read command finishes. */ static int -finished_read (void *vp, int64_t rcookie, int *error) +finished_read (unsigned valid_flag, void *vp, int64_t rcookie, int *error) { size_t i; + if (!(valid_flag & LIBNBD_CALLBACK_VALID)) + return 0; + if (gssrc == NULL) return 0; @@ -462,10 +467,13 @@ write_data (gpointer user_data) /* This callback is called from libnbd when any write command finishes. */ static int -finished_write (void *vp, int64_t wcookie, int *error) +finished_write (unsigned valid_flag, void *vp, int64_t wcookie, int *err...