summaryrefslogtreecommitdiffhomepage
path: root/src/go/unit/unit.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/go/unit/unit.go')
-rw-r--r--src/go/unit/unit.go52
1 files changed, 16 insertions, 36 deletions
diff --git a/src/go/unit/unit.go b/src/go/unit/unit.go
index 74e53ecf..82a54ecc 100644
--- a/src/go/unit/unit.go
+++ b/src/go/unit/unit.go
@@ -20,32 +20,21 @@ import (
)
type cbuf struct {
- b unsafe.Pointer
+ b C.uintptr_t
s C.size_t
- f bool
}
-func new_cbuf(buf []byte) *cbuf {
+func buf_ref(buf []byte) C.uintptr_t {
if len(buf) == 0 {
- return nil
+ return 0
}
- return &cbuf{
- getCBytes(buf), C.size_t(len(buf)), true,
- }
+ return C.uintptr_t(uintptr(unsafe.Pointer(&buf[0])))
}
-func (buf *cbuf) Close() {
- if buf == nil {
- return
- }
-
- if buf.f && buf.s > 0 {
- C.free(buf.b)
- buf.f = false
- buf.b = nil
- buf.s = 0
- }
+func (buf *cbuf) init(b []byte) {
+ buf.b = buf_ref(b)
+ buf.s = C.size_t(len(b))
}
func (buf *cbuf) GoBytes() []byte {
@@ -54,24 +43,7 @@ func (buf *cbuf) GoBytes() []byte {
return b[:0]
}
- return C.GoBytes(buf.b, C.int(buf.s))
-}
-
-type cmsg struct {
- buf cbuf
- oob cbuf
-}
-
-func new_cmsg(buf []byte, oob []byte) *cmsg {
- return &cmsg{
- buf: cbuf{getCBytes(buf), C.size_t(len(buf)), true},
- oob: cbuf{getCBytes(oob), C.size_t(len(oob)), true},
- }
-}
-
-func (msg *cmsg) Close() {
- msg.buf.Close()
- msg.oob.Close()
+ return C.GoBytes(unsafe.Pointer(uintptr(buf.b)), C.int(buf.s))
}
var nxt_go_quit bool = false
@@ -81,6 +53,14 @@ func nxt_go_set_quit() {
nxt_go_quit = true
}
+func nxt_go_warn(format string, args ...interface{}) {
+ fmt.Fprintf(os.Stderr, "[go warn] " + format + "\n", args...)
+}
+
+func nxt_go_debug(format string, args ...interface{}) {
+ // fmt.Fprintf(os.Stderr, "[go debug] " + format + "\n", args...)
+}
+
func ListenAndServe(addr string, handler http.Handler) error {
var read_port *port