diff options
author | Max Romanov <max.romanov@nginx.com> | 2019-09-18 18:31:14 +0300 |
---|---|---|
committer | Max Romanov <max.romanov@nginx.com> | 2019-09-18 18:31:14 +0300 |
commit | 84e4a6437f69b14b1cafbe7915447fdcf1d87f68 (patch) | |
tree | 1b70aa21389cc79dca1aa1d51526a99e910b1ecf /src/go/unit/request.go | |
parent | 4ea9ed309e958ad087ddcfd358688e2a2f105e39 (diff) | |
download | unit-84e4a6437f69b14b1cafbe7915447fdcf1d87f68.tar.gz unit-84e4a6437f69b14b1cafbe7915447fdcf1d87f68.tar.bz2 |
Go: do not store pointer to Go object.
To pass Go object references to C and back we use hack with casting to
unsafe and then to uintptr. However, we should not store such references
because Go not guaratnee it will be available by the same address.
Introducing map with integer key helps to avoid dereference stored address.
This closes #253 and #309 issues on GitHub.
Diffstat (limited to 'src/go/unit/request.go')
-rw-r--r-- | src/go/unit/request.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/go/unit/request.go b/src/go/unit/request.go index ad56cabb..1d8c6702 100644 --- a/src/go/unit/request.go +++ b/src/go/unit/request.go @@ -135,7 +135,7 @@ func nxt_go_request_set_tls(go_req uintptr) { //export nxt_go_request_handler func nxt_go_request_handler(go_req uintptr, h uintptr) { r := get_request(go_req) - handler := *(*http.Handler)(unsafe.Pointer(h)) + handler := get_handler(h) go func(r *request) { handler.ServeHTTP(r.response(), &r.req) |