On Thu, May 06, 2021 at 08:59:37PM -0500, Eric Blake wrote:
+/* Set (or clear) the context using the current thread */
I might add a comment here saying that you should prefer to use the
PUSH_CONTEXT_FOR_SCOPE() macro rather than calling the function
directly; or noting that the macro uses this function.
But the patch is fine, ACK.
Rich.
+struct context *
+threadlocal_push_context (struct context *ctx)
+{
+ struct threadlocal *threadlocal = pthread_getspecific (threadlocal_key);
+ struct context *ret = NULL;
+
+ if (threadlocal) {
+ ret = threadlocal->ctx;
+ threadlocal->ctx = ctx;
+ }
+ return ret;
+}
+
+void
+threadlocal_pop_context (struct context **ctx)
+{
+ threadlocal_push_context (*ctx);
+}
--
2.31.1
_______________________________________________
Libguestfs mailing list
Libguestfs(a)redhat.com
https://listman.redhat.com/mailman/listinfo/libguestfs
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
libguestfs lets you edit virtual machines. Supports shell scripting,
bindings from many languages.
http://libguestfs.org