diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2015-09-12 12:56:20 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2015-09-12 12:56:20 -0600 |
commit | ff571cf730cad687d5cfda4db719e16f3fb4c801 (patch) | |
tree | 84ecbf4c9931ebc3748116e0f321f022d99a9adf /src/nslcd_proto/func_handlerequest.go.sh | |
parent | 8e35809d4c3529dc622047c29ada0283987cc362 (diff) |
nslcd_proto:handleRequest: fix
Diffstat (limited to 'src/nslcd_proto/func_handlerequest.go.sh')
-rwxr-xr-x | src/nslcd_proto/func_handlerequest.go.sh | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/nslcd_proto/func_handlerequest.go.sh b/src/nslcd_proto/func_handlerequest.go.sh index c0e3052..4b89a8a 100755 --- a/src/nslcd_proto/func_handlerequest.go.sh +++ b/src/nslcd_proto/func_handlerequest.go.sh @@ -19,7 +19,7 @@ func handleRequest(backend Backend, in io.Reader, out io.Writer, cred Ucred) { var action int32 read(in, &action) - res := make(chan interface{}) + ch := make(chan interface{}) switch action { $( while read -r request; do @@ -36,28 +36,24 @@ while read -r request; do echo 'fmt.Fprintf(os.Stderr, "Request: %#v\n", req)' fi ) - _res := backend.${request}(cred, req) + _ch := backend.${request}(cred, req) go func() { - o, ok := <-_res - if ok { - res <- o - } else { - close(res) + defer close(ch) + for obj := range _ch { + ch <- obj } }() EOT done < "$requests" ) default: - panic(NslcdError(fmt.Sprintf("unknown request action: %#08x", action))) - } - if res == nil { - return + close(ch) + panic(NslcdError(fmt.Sprintf("Unknown request action: %#08x", action))) } write(out, NSLCD_VERSION) write(out, action) - for result, ok := <-res; ok; result, ok = <-res { + for result := range ch { write(out, NSLCD_RESULT_BEGIN) write(out, result) } |