summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/nslcd_proto/func_handlerequest.go.sh20
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)
}