Skip to content

cosmetic fixes in port.go #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 35 additions & 33 deletions src/go/unit/port.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,18 +134,19 @@ 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 {
n, oobn, err := p.snd.WriteMsgUnix(C.GoBytes(buf, buf_size),
C.GoBytes(oob, oob_size), nil)
if p == nil {
return 0
}

if err != nil {
fmt.Printf("write result %d (%d), %s\n", n, oobn, err)
}
n, oobn, err := p.snd.WriteMsgUnix(C.GoBytes(buf, buf_size),
C.GoBytes(oob, oob_size), nil)

return C.int(n)
if err != nil {
fmt.Printf("write result %d (%d), %s\n", n, oobn, err)
}

return 0
return C.int(n)

}

//export nxt_go_main_send
Expand All @@ -154,18 +155,18 @@ func nxt_go_main_send(buf unsafe.Pointer, buf_size C.int, oob unsafe.Pointer,

p := main_port()

if p != nil {
n, oobn, err := p.snd.WriteMsgUnix(C.GoBytes(buf, buf_size),
C.GoBytes(oob, oob_size), nil)
if p == nil {
return 0
}

if err != nil {
fmt.Printf("write result %d (%d), %s\n", n, oobn, err)
}
n, oobn, err := p.snd.WriteMsgUnix(C.GoBytes(buf, buf_size),
C.GoBytes(oob, oob_size), nil)

return C.int(n)
if err != nil {
fmt.Printf("write result %d (%d), %s\n", n, oobn, err)
}

return 0
return C.int(n)
}

func new_port(pid int, id int, t int, rcv int, snd int) *port {
Expand Down Expand Up @@ -200,26 +201,27 @@ func (p *port) read(handler http.Handler) error {

if c_req == 0 {
m.Close()
} else {
r := find_request(c_req)

go func(r *request) {
if handler == nil {
handler = http.DefaultServeMux
}
return nil
}

handler.ServeHTTP(r.response(), &r.req)
r.done()
}(r)
r := find_request(c_req)

if len(r.msgs) == 0 {
r.push(m)
} else if r.ch != nil {
r.ch <- m
} else {
m.Close()
go func(r *request) {
if handler == nil {
handler = http.DefaultServeMux
}

handler.ServeHTTP(r.response(), &r.req)
r.done()
}(r)

if len(r.msgs) == 0 {
r.push(m)
} else if r.ch != nil {
r.ch <- m
} else {
m.Close()
}

return err
return nil
}