Displaying 3 results from an estimated 3 matches for "getconn".
Did you mean:
getconf
2020 Apr 21
0
Re: [PATCH nbdkit v2] Add the ability to write plugins in golang.
...f c_readonly != 0 {
readonly = true
}
h, err := pluginImpl.Open(readonly)
if err != nil {
set_error(err)
return nil
}
if h == 0 {
panic("Open method: handle must be != 0")
}
id := connectionID++
connectionMap[id] = h
return unsafe.Pointer(uintptr(id))
}
func getConn(handle unsafe.Pointer) PluginConnectionInterface {
id := uint(uintptr(handle))
conn, ok = connectionMap[id]
if !ok {
panic("Connection %d was not open", id)
}
}
//export implClose
func implClose(handle unsafe.Pointer) {
conn := getConn(handle)
conn.Close()...
2020 Apr 21
2
[PATCH nbdkit v2] Add the ability to write plugins in golang.
Thanks: Dan Berrangé
XXX UNFINISHED:
- Is using uintptr for the handle a good idea? Plugins must return
something != 0. In other languages we would allow plugins to
return an arbitrary object here, but this is not possible in golang
because of lack of GC roots.
- Default can_* methods are hard to implement. Ideally we would be
able to test if a user plugin implements a
2020 Apr 23
2
Re: [PATCH nbdkit v2] Add the ability to write plugins in golang.
...readonly C.int) unsafe.Pointer {
+ readonly := false
+ if c_readonly != 0 {
+ readonly = true
+ }
+ h, err := pluginImpl.Open(readonly)
+ if err != nil {
+ set_error(err)
+ return nil
+ }
+ id := nextConnectionId
+ nextConnectionId++
+ connectionMap[id] = h
+ return unsafe.Pointer(id)
+}
+
+func getConn(handle unsafe.Pointer) ConnectionInterface {
+ id := uintptr(handle)
+ h, ok := connectionMap[id]
+ if !ok {
+ panic(fmt.Sprintf("connection %d was not open", id))
+ }
+ return h
+}
+
+//export implClose
+func implClose(handle unsafe.Pointer) {
+ h := getConn(handle)
+ h.Close()
+ id :=...