search for: unlocked_last_error

Displaying 4 results from an estimated 4 matches for "unlocked_last_error".

2015 Jun 11
1
Re: [PATCH 2/5] threads: Acquire and release the lock around each public guestfs_* API.
...gt; difficult to debug. Enable DEBUG_LOCK to add some prints which can > help. There's some way this could be simplified: > const char * > guestfs_last_error (guestfs_h *g) > { > - return g->last_error; > + const char *r; > + > + ACQUIRE_LOCK (g); > + r = unlocked_last_error (g); > + RELEASE_LOCK (g); > + return r; > +} (picking this because it is the first ACQUIRE_LOCK ... RELEASE_LOCK pattern in the patch) there could be an extra macro to do a "stack lock", using the cleanup attribute we use already; something like: static inline guestfs_h *a...
2015 Jun 06
0
[PATCH 2/5] threads: Acquire and release the lock around each public guestfs_* API.
...;; pr " return ret_v;\n"; pr "}\n\n" in diff --git a/src/errors.c b/src/errors.c index 2d3ae84..d9959b2 100644 --- a/src/errors.c +++ b/src/errors.c @@ -29,16 +29,38 @@ #include "guestfs.h" #include "guestfs-internal.h" +static const char * +unlocked_last_error (guestfs_h *g) +{ + return g->last_error; +} + const char * guestfs_last_error (guestfs_h *g) { - return g->last_error; + const char *r; + + ACQUIRE_LOCK (g); + r = unlocked_last_error (g); + RELEASE_LOCK (g); + return r; +} + +static int +unlocked_last_errno (guestfs_h *g) +{ + re...
2015 Jun 06
7
[PATCH 0/5] Add support for thread-safe handle.
This patch isn't ready to go upstream. In fact, I think we might do a quick 1.30 release soon, and save this patch, and also the extensive changes proposed for the test suite[1], to after 1.30. Currently it is not safe to use the same handle from multiple threads, unless you implement your own mutexes. See: http://libguestfs.org/guestfs.3.html#multiple-handles-and-multiple-threads These
2015 Jun 06
0
[PATCH 3/5] threads: Use thread-local storage for errors.
...+ g->error_data_list = ret; + gl_lock_unlock (g->error_data_list_lock); + + /* Set the TLS to point to the struct. This is safe because we + * should have acquired the handle lock. + */ + gl_tls_set (g->error_data, ret); + } + + return ret; +} + static const char * unlocked_last_error (guestfs_h *g) { - return g->last_error; + return get_error_data (g)->last_error; } const char * @@ -49,7 +171,7 @@ guestfs_last_error (guestfs_h *g) static int unlocked_last_errno (guestfs_h *g) { - return g->last_errnum; + return get_error_data (g)->last_errnum; } int...