From d14c0774c7e6f372dfebcfcafdcac718b7e28789 Mon Sep 17 00:00:00 2001 From: Max Romanov Date: Wed, 6 Dec 2017 12:16:02 +0300 Subject: Go: removing request registry. Passing unsafe.Pointers (void *) from Go to C is complicated by an attempt to make such pointers less unsafe. A straightforward optimization is to replace 'unsafe.Pointer' with 'uintptr' (thanks to Xin Huang for the idea: https://stackoverflow.com/a/44826533 ). As a result, request registry with mutex is gone. --- src/go/unit/response.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/go/unit/response.go') diff --git a/src/go/unit/response.go b/src/go/unit/response.go index 18daa2f3..258a82c9 100644 --- a/src/go/unit/response.go +++ b/src/go/unit/response.go @@ -13,7 +13,6 @@ import "C" import ( "fmt" "net/http" - "os" ) type response struct { @@ -43,16 +42,15 @@ func (r *response) Write(p []byte) (n int, err error) { } l := C.size_t(len(p)) - b := getCBytes(p) + b := buf_ref(p) res := C.nxt_go_response_write(r.c_req, b, l) - C.free(b) return int(res), nil } func (r *response) WriteHeader(code int) { if r.headerSent { // Note: explicitly using Stderr, as Stdout is our HTTP output. - fmt.Fprintf(os.Stderr, "CGI attempted to write header twice") + nxt_go_warn("multiple response.WriteHeader calls") return } r.headerSent = true -- cgit