On Thu, Oct 28, 2021 at 07:55:39PM +0200, Laszlo Ersek wrote:
On 10/28/21 16:24, Richard W.M. Jones wrote:
> +#ifdef HAVE_STDATOMIC_H
> +#include <stdatomic.h>
> +#else
> +/* Some old platforms lack atomic types, but this is only used for
> + * debug messages.
> + */
> +#define _Atomic /**/
> +#endif
...
> +/* Send command to the background thread and wait for
completion.
> + *
> + * Returns 0 for OK
> + * On error, calls nbdkit_error and returns -1.
> + */
> +int
> +send_command_and_wait (struct vddk_handle *h, struct command *cmd)
> +{
> + static _Atomic uint64_t id = 0;
Ugh.
_Atomic is from C11, and it comes with a huge theoretical baggage
(section "5.1.2.4 Multi-threaded executions and data races"). Do we
really need this? For example:
[theoretical stuff snipped]
Sure thing, I'll put it in the handle structure and protect it with
the command queue lock.
I think I'll push this with the above change.
There are quite a few other cases of _Atomic in nbdkit & libnbd if
you're feeling spirited enough to check any of them :-)
Thanks,
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
virt-builder quickly builds VMs from scratch
http://libguestfs.org/virt-builder.1.html