Displaying 8 results from an estimated 8 matches for "closed_handle_error".
2023 Feb 24
1
no way to force-close NBD handle in nbdsh
...er), I realized it is extremely hard
to trigger this using nbdsh, but easy to do in C or the Go bindings.
In the Go bindings, we intentionally coded things so that the Go
structure knows if its underlying C pointer is live or not; it exposes
a way to force early closure, then the bindings return a
closed_handle_error() if early closure has happened.  We probably need
to support something similar in the Python bindings.
As a short-term hack, I tried directly calling h.__del__() - this is
not a good idea, as our current __del__ implementation is not designed
to be called twice, and when the later garbage collect...
2023 Feb 25
1
no way to force-close NBD handle in nbdsh
...y hard
> to trigger this using nbdsh, but easy to do in C or the Go bindings.
> 
> In the Go bindings, we intentionally coded things so that the Go
> structure knows if its underlying C pointer is live or not; it exposes
> a way to force early closure, then the bindings return a
> closed_handle_error() if early closure has happened.  We probably need
> to support something similar in the Python bindings.
> 
> As a short-term hack, I tried directly calling h.__del__() - this is
> not a good idea, as our current __del__ implementation is not designed
> to be called twice, and when...
2020 Mar 17
5
[PATCH libnbd v2 0/3] Unfinished golang bindings.
These bindings get as far as running very simple connections.
However there are many missing parts still:
* No callbacks.
* No functions which handle buffers (pread/pwrite!)
This is posted just for general early interest, not even for review.
Rich.
2020 Mar 17
0
[PATCH libnbd] Add outline framework for Go language bindings (golang).
...)
+}
+
+func get_error (op string) *LibnbdError {
+    // NB: DO NOT try to free c_errmsg!
+    c_errmsg := C.nbd_get_error ()
+    errmsg := C.GoString (c_errmsg)
+
+    errno := syscall.Errno (C.nbd_get_errno ())
+
+    return &LibnbdError{ Op : op, Errmsg : errmsg, Errno : errno }
+}
+
+func closed_handle_error (op string) *LibnbdError {
+    return &LibnbdError{ Op : op, Errmsg : \"handle is closed\",
+                         Errno : syscall.Errno (0) }
+}
+
+/* Close the handle. */
+func (h *Libnbd) Close () *LibnbdError {
+    if h.h == nil {
+        return closed_handle_error (\"c...
2020 Mar 17
0
[PATCH libnbd v2 2/3] Add outline framework for Go language bindings (golang).
...+func (e *LibnbdError) Error() string {
+     return e.String()
+}
+
+func get_error (op string, c_err C.struct_error) *LibnbdError {
+    errmsg := C.GoString (c_err.error)
+    errno := syscall.Errno (c_err.errnum)
+    return &LibnbdError{ Op : op, Errmsg : errmsg, Errno : errno }
+}
+
+func closed_handle_error (op string) *LibnbdError {
+    return &LibnbdError{ Op : op, Errmsg : \"handle is closed\",
+                         Errno : syscall.Errno (0) }
+}
+
+/* Create a new handle. */
+func Create () (*Libnbd, error) {
+    c_err := C.struct_error{}
+    c_h := C._nbd_create_wrapper (&...
2020 Mar 24
1
[PATCH libnbd v3] Add Go language bindings (golang) (RHBZ#1814538).
This feature is roughly finished now, although it needs a few more
tests and some examples.
It's pretty much up to par with all the other bindings, but it lacks a
completely safe AIO buffer.  It won't stop you from freeing the buffer
too early) because golang's GC inexplicably lacks a way to declare a
root from C.  I can probably do it with a global variable and ref
counting on the
2020 Mar 17
0
[PATCH libnbd v2 3/3] golang: Add straightforward bindings, without callbacks.
...) args;
+  if optargs <> [] then (
+    if !comma then pr ", ";
+    comma := true;
+    pr "optargs *Optargs_%s" uname
+  );
+  pr ") (%s, error)" (go_ret_type ret);
+  pr " {\n";
+  pr "    if h.h == nil {\n";
+  pr "        return %s, closed_handle_error (\"%s\")\n"
+    (go_ret_error ret) name;
+  pr "    }\n";
+  pr "\n";
+  pr "    c_err := C.struct_error{}\n";
+  List.iter (
+    function
+    | Bool n ->
+       pr "    c_%s := C.bool (%s)\n" n n
+    | BytesIn (n, len) ->
+       pr...
2020 Mar 25
3
[PATCH libnbd v4] Add Go language bindings (golang) (RHBZ#1814538).
Now runs a complete set of tests, notably including the AIO test.
File descriptors are passed in and out as plain ints (instead of
*os.File) for a couple of reasons: (1) We have to pass the plain int
to syscall.Select.  (2) Turning an fd into an os.File causes golang to
set the blocking flag which is deeply unhelpful.
Rich.