Cosmetic fixes in port.go.
This closes on GitHub.
From
@@ -134,7 +134,10 @@ func nxt_go_port_send(pid C.int, id C.int, buf unsafe.Pointer, buf_size C.int,
p := find_port(key)
- if p != nil {
+ if p == nil {
+ return 0
+ }
+
n, oobn, err := p.snd.WriteMsgUnix(C.GoBytes(buf, buf_size),
C.GoBytes(oob, oob_size), nil)
@@ -143,9 +146,7 @@ func nxt_go_port_send(pid C.int, id C.int, buf unsafe.Pointer, buf_size C.int,
}
return C.int(n)
- }
- return 0
}
//export nxt_go_main_send
@@ -154,7 +155,10 @@ func nxt_go_main_send(buf unsafe.Pointer, buf_size C.int, oob unsafe.Pointer,
p := main_port()
- if p != nil {
+ if p == nil {
+ return 0
+ }
+
n, oobn, err := p.snd.WriteMsgUnix(C.GoBytes(buf, buf_size),
C.GoBytes(oob, oob_size), nil)
@@ -165,9 +169,6 @@ func nxt_go_main_send(buf unsafe.Pointer, buf_size C.int, oob unsafe.Pointer,
return C.int(n)
}
- return 0
-}
-
func new_port(pid int, id int, t int, rcv int, snd int) *port {
p := &port{
key: port_key{
@@ -200,7 +201,9 @@ func (p *port) read(handler http.Handler) error {
if c_req == 0 {
m.Close()
- } else {
+ return nil
+ }
+
r := find_request(c_req)
go func(r *request) {
@@ -219,7 +222,6 @@ func (p *port) read(handler http.Handler) error {
} else {
m.Close()
}
- }
- return err
+ return nil
}
