Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
34dd450f
Commit
34dd450f
authored
Feb 14, 2011
by
Roger Peppe
Committed by
Rob Pike
Feb 14, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rpc: properly discard values.
R=r, rsc, r2 CC=golang-dev
https://golang.org/cl/4171050
parent
ff7d7b27
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
6 deletions
+14
-6
src/pkg/rpc/client.go
src/pkg/rpc/client.go
+4
-3
src/pkg/rpc/jsonrpc/client.go
src/pkg/rpc/jsonrpc/client.go
+3
-0
src/pkg/rpc/jsonrpc/server.go
src/pkg/rpc/jsonrpc/server.go
+3
-0
src/pkg/rpc/server.go
src/pkg/rpc/server.go
+4
-3
No files found.
src/pkg/rpc/client.go
View file @
34dd450f
...
...
@@ -53,7 +53,9 @@ type Client struct {
// The client calls WriteRequest to write a request to the connection
// and calls ReadResponseHeader and ReadResponseBody in pairs
// to read responses. The client calls Close when finished with the
// connection.
// connection. ReadResponseBody may be called with a nil
// argument to force the body of the response to be read and then
// discarded.
type
ClientCodec
interface
{
WriteRequest
(
*
Request
,
interface
{})
os
.
Error
ReadResponseHeader
(
*
Response
)
os
.
Error
...
...
@@ -89,7 +91,6 @@ func (client *Client) send(c *Call) {
func
(
client
*
Client
)
input
()
{
var
err
os
.
Error
var
marker
struct
{}
for
err
==
nil
{
response
:=
new
(
Response
)
err
=
client
.
codec
.
ReadResponseHeader
(
response
)
...
...
@@ -115,7 +116,7 @@ func (client *Client) input() {
// any subsequent requests will get the ReadResponseBody
// error if there is one.
c
.
Error
=
ServerError
(
response
.
Error
)
err
=
client
.
codec
.
ReadResponseBody
(
&
marker
)
err
=
client
.
codec
.
ReadResponseBody
(
nil
)
if
err
!=
nil
{
err
=
os
.
ErrorString
(
"reading error body: "
+
err
.
String
())
}
...
...
src/pkg/rpc/jsonrpc/client.go
View file @
34dd450f
...
...
@@ -98,6 +98,9 @@ func (c *clientCodec) ReadResponseHeader(r *rpc.Response) os.Error {
}
func
(
c
*
clientCodec
)
ReadResponseBody
(
x
interface
{})
os
.
Error
{
if
x
==
nil
{
return
nil
}
return
json
.
Unmarshal
(
*
c
.
resp
.
Result
,
x
)
}
...
...
src/pkg/rpc/jsonrpc/server.go
View file @
34dd450f
...
...
@@ -85,6 +85,9 @@ func (c *serverCodec) ReadRequestHeader(r *rpc.Request) os.Error {
}
func
(
c
*
serverCodec
)
ReadRequestBody
(
x
interface
{})
os
.
Error
{
if
x
==
nil
{
return
nil
}
// JSON params is array value.
// RPC params is struct.
// Unmarshal into array containing struct for now.
...
...
src/pkg/rpc/server.go
View file @
34dd450f
...
...
@@ -302,7 +302,7 @@ type InvalidRequest struct {
Marker
int
}
var
invalidRequest
=
InvalidRequest
{
1
}
var
invalidRequest
=
InvalidRequest
{}
func
_new
(
t
*
reflect
.
PtrType
)
*
reflect
.
PtrValue
{
v
:=
reflect
.
MakeZero
(
t
)
.
(
*
reflect
.
PtrValue
)
...
...
@@ -399,7 +399,7 @@ func (server *Server) ServeCodec(codec ServerCodec) {
break
}
// discard body
codec
.
ReadRequestBody
(
n
ew
(
interface
{})
)
codec
.
ReadRequestBody
(
n
il
)
// send a response if we actually managed to read a header.
if
req
!=
nil
{
...
...
@@ -486,7 +486,8 @@ func RegisterName(name string, rcvr interface{}) os.Error {
// The server calls ReadRequestHeader and ReadRequestBody in pairs
// to read requests from the connection, and it calls WriteResponse to
// write a response back. The server calls Close when finished with the
// connection.
// connection. ReadRequestBody may be called with a nil
// argument to force the body of the request to be read and discarded.
type
ServerCodec
interface
{
ReadRequestHeader
(
*
Request
)
os
.
Error
ReadRequestBody
(
interface
{})
os
.
Error
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment