search for: last_error

Displaying 20 results from an estimated 85 matches for "last_error".

2023 Mar 08
2
[libnbd PATCH v2] lib/errors.c: Fix assert fail in exit path in multi-threaded code
...bd_get_error ()); abort_option (h); nbd_internal_abort_commands (h, &h->cmds_to_issue); nbd_internal_abort_commands (h, &h->cmds_in_flight); diff --git a/lib/errors.c b/lib/errors.c index 8b77650e..133c752b 100644 --- a/lib/errors.c +++ b/lib/errors.c @@ -34,6 +34,8 @@ struct last_error { /* Thread-local storage of the last error. */ static pthread_key_t errors_key; +/* Zero if errors_key is invalid, else 1 + threads using errors_key. */ +static _Atomic int key_use_count; static void free_errors_key (void *vp) LIBNBD_ATTRIBUTE_NONNULL (1); @@ -51,6 +53,7 @@ errors_key_create...
2016 Jul 24
2
Lifecycle of a connection to libvirtd
...of a disconnect Are those steps needed? Randomly checking virConnectIsAlive() doesn't seem reliable. Checking individual error codes either (maybe I will miss one of them or misinterpret another one). virsh code uses those error codes to check if there is a disconnection: (((last_error->code == VIR_ERR_SYSTEM_ERROR) && (last_error->domain == VIR_FROM_REMOTE)) || (last_error->code == VIR_ERR_RPC) || (last_error->code == VIR_ERR_NO_CONNECT) || (last_error->code == VIR_ERR_INVALID_CONN)))) Any hint? --...
2019 Aug 13
0
[nbdkit PATCH 2/2] plugins: Permit ENOTSUP as synonym for EOPNOTSUPP
...llocate during trim: %m"); diff --git a/plugins/perl/perl.c b/plugins/perl/perl.c index e8395dd2..59b26788 100644 --- a/plugins/perl/perl.c +++ b/plugins/perl/perl.c @@ -505,7 +505,7 @@ perl_zero (void *handle, uint32_t count, uint64_t offset, int may_trim) FREETMPS; LEAVE; - if (last_error == EOPNOTSUPP) { + if (last_error == EOPNOTSUPP || last_error == ENOTSUP) { /* When user requests this particular error, we want to gracefully fall back, and to accomodate both a normal return and an exception. */ diff --git a/plugins/python/python.c b/plugins/python/p...
2017 Jun 27
0
[PATCH v3 3/5] threads: Use thread-local storage for errors.
We permit the following constructs in libguestfs code: if (guestfs_some_call (g) == -1) { fprintf (stderr, "failed: error is %s\n", guestfs_last_error (g)); } and: guestfs_push_error_handler (g, NULL, NULL); guestfs_some_call (g); guestfs_pop_error_handler (g); Neither of these would be safe if we allowed the handle to be used from threads concurrently, since the error string or error handler could be changed by another thread. Solve...
2015 Jun 06
0
[PATCH 3/5] threads: Use thread-local storage for errors.
We permit the following constructs in libguestfs code: if (guestfs_some_call (g) == -1) { fprintf (stderr, "failed: error is %s\n", guestfs_last_error (g)); } and: guestfs_push_error_handler (g, NULL, NULL); guestfs_some_call (g); guestfs_pop_error_handler (g); Neither of these would be safe if we allowed the handle to be used from threads concurrently, since the error string or error handler could be changed by another thread. Solve...
2019 Aug 13
3
[nbdkit PATCH 0/2] errno cleanup patches
I ran into these while trying to prepare patches to add NBD_CMD_FLAG_FAST_ZERO, which will expose a new NBD_ENOTSUP wire value. Eric Blake (2): plugins: Don't lose original error when emulating FUA plugins: Permit ENOTSUP as synonym for EOPNOTSUPP docs/nbdkit-filter.pod | 11 ++++++----- docs/nbdkit-plugin.pod | 12 +++++++----- plugins/file/file.c | 16 +++++++++++-----
2016 Jul 25
0
Re: Lifecycle of a connection to libvirtd
...those steps needed? Randomly checking virConnectIsAlive() doesn't >seem reliable. Checking individual error codes either (maybe I will miss >one of them or misinterpret another one). > >virsh code uses those error codes to check if there is a disconnection: > > (((last_error->code == VIR_ERR_SYSTEM_ERROR) && > (last_error->domain == VIR_FROM_REMOTE)) || > (last_error->code == VIR_ERR_RPC) || > (last_error->code == VIR_ERR_NO_CONNECT) || > (last_error->code == VIR_ERR_INVALID_CONN)))...
2023 Mar 08
2
[PATCH libnbd] lib/errors.c: Fix assert fail in exit path in multi-threaded code
...error ()); abort_option (h); nbd_internal_abort_commands (h, &h->cmds_to_issue); nbd_internal_abort_commands (h, &h->cmds_in_flight); diff --git a/lib/errors.c b/lib/errors.c index 8b77650ef3..9142a0843e 100644 --- a/lib/errors.c +++ b/lib/errors.c @@ -93,7 +93,10 @@ allocate_last_error_on_demand (void) last_error = calloc (1, sizeof *last_error); if (last_error) { int err = pthread_setspecific (errors_key, last_error); - if (err != 0) { + /* Ignore EINVAL because that can happen in a race with other + * threads when we are exiting. + */ +...
2017 Feb 02
0
[nbdkit PATCH 2/2] ruby: Support zero callback
...7968 100644 --- a/plugins/ruby/ruby.c +++ b/plugins/ruby/ruby.c @@ -36,12 +36,14 @@ #include <stdio.h> #include <stdlib.h> #include <assert.h> +#include <errno.h> #include <nbdkit-plugin.h> #include <ruby.h> static VALUE nbdkit_module = Qnil; +static int last_error; static VALUE set_error(VALUE self, VALUE arg) @@ -58,6 +60,7 @@ set_error(VALUE self, VALUE arg) } else { err = NUM2INT(arg); } + last_error = err; nbdkit_set_error(err); return Qnil; } @@ -367,6 +370,30 @@ plugin_rb_trim (void *handle, uint32_t count, uint64_t offset) } s...
2017 Jan 26
0
[nbdkit PATCH v2 6/6] python: Support zero callback
...or(errno.EOPNOTSUPP)>. + =back =head2 MISSING CALLBACKS diff --git a/plugins/python/python.c b/plugins/python/python.c index 4a0ff50..644ced4 100644 --- a/plugins/python/python.c +++ b/plugins/python/python.c @@ -54,6 +54,8 @@ static const char *script; static PyObject *module; +static int last_error; + static PyObject * set_error (PyObject *self, PyObject *args) { @@ -62,6 +64,7 @@ set_error (PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "i", &err)) return NULL; nbdkit_set_error (err); + last_error = err; Py_RETURN_NONE; } @@ -441,6 +444,48 @@ py...
2017 Jan 27
0
[nbdkit PATCH v3 4/4] python: Support zero callback
...or(errno.EOPNOTSUPP)>. + =back =head2 MISSING CALLBACKS diff --git a/plugins/python/python.c b/plugins/python/python.c index 631411e..895a361 100644 --- a/plugins/python/python.c +++ b/plugins/python/python.c @@ -54,6 +54,8 @@ static const char *script; static PyObject *module; +static int last_error; + static PyObject * set_error (PyObject *self, PyObject *args) { @@ -62,6 +64,7 @@ set_error (PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "i", &err)) return NULL; nbdkit_set_error (err); + last_error = err; Py_RETURN_NONE; } @@ -441,6 +444,48 @@ py...
2015 Jun 16
5
[PATCH threads v2 0/5] Add support for thread-safe handle.
Previous discussion here: https://www.redhat.com/archives/libguestfs/2015-June/thread.html#00048 v2: - Use a cleanup handler to release the lock. - Rebase to upstream. Note I have not fixed the problem(s) with error handling (patch 3).
2019 Nov 22
0
[PATCH nbdkit v2 01/10] python: Use PyObject_CallFunction instead of constructing the tuple.
...n/python.c +++ b/plugins/python/python.c @@ -557,26 +557,21 @@ py_zero (void *handle, uint32_t count, uint64_t offset, int may_trim) { PyObject *obj = handle; PyObject *fn; - PyObject *args; PyObject *r; if (callback_defined ("zero", &fn)) { PyErr_Clear (); last_error = 0; - args = PyTuple_New (4); - Py_INCREF (obj); /* decremented by Py_DECREF (args) */ - PyTuple_SetItem (args, 0, obj); - PyTuple_SetItem (args, 1, PyLong_FromUnsignedLongLong (count)); - PyTuple_SetItem (args, 2, PyLong_FromUnsignedLongLong (offset)); - PyTuple_SetItem (args, 3...
2019 Nov 21
0
[PATCH nbdkit 1/8] python: Use PyObject_CallFunction instead of constructing the tuple.
...n/python.c +++ b/plugins/python/python.c @@ -557,26 +557,21 @@ py_zero (void *handle, uint32_t count, uint64_t offset, int may_trim) { PyObject *obj = handle; PyObject *fn; - PyObject *args; PyObject *r; if (callback_defined ("zero", &fn)) { PyErr_Clear (); last_error = 0; - args = PyTuple_New (4); - Py_INCREF (obj); /* decremented by Py_DECREF (args) */ - PyTuple_SetItem (args, 0, obj); - PyTuple_SetItem (args, 1, PyLong_FromUnsignedLongLong (count)); - PyTuple_SetItem (args, 2, PyLong_FromUnsignedLongLong (offset)); - PyTuple_SetItem (args, 3...
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
2023 Mar 09
2
[PATCH libnbd v3] lib/errors.c: Fix assert fail in exit path in multi-threaded code
...chose to leak the pthread_key_t on the exit path. --- lib/errors.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/errors.c b/lib/errors.c index 8b77650ef3..6fbfaacd34 100644 --- a/lib/errors.c +++ b/lib/errors.c @@ -69,7 +69,11 @@ errors_key_destroy (void) free (last_error->error); free (last_error); } - pthread_key_delete (errors_key); + + /* We could do this, but that causes a race condition described here: + * https://listman.redhat.com/archives/libguestfs/2023-March/031002.html + */ + //pthread_key_delete (errors_key); } /* This is called wh...
2023 Mar 09
1
[PATCH libnbd v3] lib/errors.c: Fix assert fail in exit path in multi-threaded code
...> --- > lib/errors.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/lib/errors.c b/lib/errors.c > index 8b77650ef3..6fbfaacd34 100644 > --- a/lib/errors.c > +++ b/lib/errors.c > @@ -69,7 +69,11 @@ errors_key_destroy (void) > free (last_error->error); > free (last_error); > } > - pthread_key_delete (errors_key); > + > + /* We could do this, but that causes a race condition described here: > + * https://listman.redhat.com/archives/libguestfs/2023-March/031002.html > + */ > + //pthread_key_delete...
2023 Apr 03
4
Simple Stacking of Two Columns
...rror NamesLong<-stack(NamesWide$Name1,NamesWide$Names2) Error in if (drop) { : argument is of length zero So does bind_rows > NamesLong<-dplyr::bind_rows(NamesWide$Name1,NamesWide$Name2) Error in `dplyr::bind_rows()`: ! Argument 1 must be a data frame or a named atomic vector. Run `rlang::last_error()` to see where the error occurred. I tried making separate dataframes to get around the error in bind_rows but it puts the data in two different columns Name1<-data.frame(c("Tom","Dick")) Name2<-data.frame(c("Larry","Curly")) NamesLong<-dplyr::bind...
2017 Jun 27
9
[PATCH v3 0/5] threads: Add support for thread-safe handle.
...18.html I have rebased and tidied up the patches, fixing a few spelling mistakes, but they are broadly the same as before. I also ran all the tests, which pass. As with the previous versions, this makes a change to the API, where you can no longer pass a handle between threads and expect guestfs_last_error() to work. I'm somewhat more sanguine about this change, since using the API like that is abstruse and no one should be expecting that to have worked. Rich.
2020 Nov 21
3
Error in unsplit() with tibbles
...ble(mtcars, rownames = NULL) > s <- split(mtcars_tb, mtcars_tb$gear) > unsplit(s, mtcars_tb$gear) Error: Must subset rows with a valid subscript vector. ? Logical subscripts must match the size of the indexed input. x Input has size 15 but subscript `rep(NA, len)` has size 32. Run `rlang::last_error()` to see where the error occurred. Tibble seems to (rightly) complain, that a logical vector has been used for subsetting which does not have the same length as the data.frame (rows). Since `NA` is a logical value, the subset should be changed to `NA_integer_` in `unsplit()`: > unsplit functi...