Commit 50c04132 authored by Rob Pike's avatar Rob Pike

fix bug causing empty strings to be become non-nil errors on client side of rpc connection.

R=rsc
CC=golang-dev
https://golang.org/cl/155078
parent bcb46c85
......@@ -83,7 +83,12 @@ func (client *Client) input() {
client.pending[seq] = c, false;
client.mutex.Unlock();
err = client.dec.Decode(c.Reply);
c.Error = os.ErrorString(response.Error);
// Empty strings should turn into nil os.Errors
if response.Error != "" {
c.Error = os.ErrorString(response.Error)
} else {
c.Error = nil
}
// We don't want to block here. It is the caller's responsibility to make
// sure the channel has enough buffer space. See comment in Go().
_ = c.Done <- c; // do not block
......
......@@ -276,7 +276,9 @@ func sendResponse(sending *sync.Mutex, req *Request, reply interface{}, enc *gob
resp := new(Response);
// Encode the response header
resp.ServiceMethod = req.ServiceMethod;
resp.Error = errmsg;
if errmsg != "" {
resp.Error = errmsg
}
resp.Seq = req.Seq;
sending.Lock();
enc.Encode(resp);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment