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
51b8d23e
Commit
51b8d23e
authored
Jan 12, 2011
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rpc: export names in debug service so it works with template changes
R=dsymonds CC=golang-dev
https://golang.org/cl/3760049
parent
6f6b7e3a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
18 deletions
+25
-18
src/pkg/rpc/debug.go
src/pkg/rpc/debug.go
+13
-13
src/pkg/rpc/server.go
src/pkg/rpc/server.go
+12
-5
No files found.
src/pkg/rpc/debug.go
View file @
51b8d23e
...
...
@@ -21,14 +21,14 @@ const debugText = `<html>
<title>Services</title>
{.repeated section @}
<hr>
Service {
n
ame}
Service {
N
ame}
<hr>
<table>
<th align=center>Method</th><th align=center>Calls</th>
{.repeated section
meth
}
{.repeated section
Method
}
<tr>
<td align=left font=fixed>{
name}({m.argType}, {m.r
eplyType}) os.Error</td>
<td align=center>{
m.n
umCalls}</td>
<td align=left font=fixed>{
Name}({Type.ArgType}, {Type.R
eplyType}) os.Error</td>
<td align=center>{
Type.N
umCalls}</td>
</tr>
{.end}
</table>
...
...
@@ -39,26 +39,26 @@ const debugText = `<html>
var
debug
=
template
.
MustParse
(
debugText
,
nil
)
type
debugMethod
struct
{
m
*
methodType
n
ame
string
Type
*
methodType
N
ame
string
}
type
methodArray
[]
debugMethod
type
debugService
struct
{
s
*
service
name
string
meth
methodArray
Service
*
service
Name
string
Method
methodArray
}
type
serviceArray
[]
debugService
func
(
s
serviceArray
)
Len
()
int
{
return
len
(
s
)
}
func
(
s
serviceArray
)
Less
(
i
,
j
int
)
bool
{
return
s
[
i
]
.
name
<
s
[
j
]
.
n
ame
}
func
(
s
serviceArray
)
Less
(
i
,
j
int
)
bool
{
return
s
[
i
]
.
Name
<
s
[
j
]
.
N
ame
}
func
(
s
serviceArray
)
Swap
(
i
,
j
int
)
{
s
[
i
],
s
[
j
]
=
s
[
j
],
s
[
i
]
}
func
(
m
methodArray
)
Len
()
int
{
return
len
(
m
)
}
func
(
m
methodArray
)
Less
(
i
,
j
int
)
bool
{
return
m
[
i
]
.
name
<
m
[
j
]
.
n
ame
}
func
(
m
methodArray
)
Less
(
i
,
j
int
)
bool
{
return
m
[
i
]
.
Name
<
m
[
j
]
.
N
ame
}
func
(
m
methodArray
)
Swap
(
i
,
j
int
)
{
m
[
i
],
m
[
j
]
=
m
[
j
],
m
[
i
]
}
type
debugHTTP
struct
{
...
...
@@ -75,10 +75,10 @@ func (server debugHTTP) ServeHTTP(w http.ResponseWriter, req *http.Request) {
services
[
i
]
=
debugService
{
service
,
sname
,
make
(
methodArray
,
len
(
service
.
method
))}
j
:=
0
for
mname
,
method
:=
range
service
.
method
{
services
[
i
]
.
meth
[
j
]
=
debugMethod
{
method
,
mname
}
services
[
i
]
.
Method
[
j
]
=
debugMethod
{
method
,
mname
}
j
++
}
sort
.
Sort
(
services
[
i
]
.
meth
)
sort
.
Sort
(
services
[
i
]
.
Method
)
i
++
}
server
.
Unlock
()
...
...
src/pkg/rpc/server.go
View file @
51b8d23e
...
...
@@ -137,8 +137,8 @@ var typeOfOsError = reflect.Typeof(unusedError).(*reflect.PtrType).Elem()
type
methodType
struct
{
sync
.
Mutex
// protects counters
method
reflect
.
Method
a
rgType
*
reflect
.
PtrType
r
eplyType
*
reflect
.
PtrType
A
rgType
*
reflect
.
PtrType
R
eplyType
*
reflect
.
PtrType
numCalls
uint
}
...
...
@@ -285,7 +285,7 @@ func (server *Server) register(rcvr interface{}, name string, useName bool) os.E
log
.
Println
(
"method"
,
mname
,
"returns"
,
returnType
.
String
(),
"not os.Error"
)
continue
}
s
.
method
[
mname
]
=
&
methodType
{
method
:
method
,
argType
:
argType
,
r
eplyType
:
replyType
}
s
.
method
[
mname
]
=
&
methodType
{
method
:
method
,
ArgType
:
argType
,
R
eplyType
:
replyType
}
}
if
len
(
s
.
method
)
==
0
{
...
...
@@ -326,6 +326,13 @@ func sendResponse(sending *sync.Mutex, req *Request, reply interface{}, codec Se
sending
.
Unlock
()
}
func
(
m
*
methodType
)
NumCalls
()
(
n
uint
)
{
m
.
Lock
()
n
=
m
.
numCalls
m
.
Unlock
()
return
n
}
func
(
s
*
service
)
call
(
sending
*
sync
.
Mutex
,
mtype
*
methodType
,
req
*
Request
,
argv
,
replyv
reflect
.
Value
,
codec
ServerCodec
)
{
mtype
.
Lock
()
mtype
.
numCalls
++
...
...
@@ -418,8 +425,8 @@ func (server *Server) ServeCodec(codec ServerCodec) {
continue
}
// Decode the argument value.
argv
:=
_new
(
mtype
.
a
rgType
)
replyv
:=
_new
(
mtype
.
r
eplyType
)
argv
:=
_new
(
mtype
.
A
rgType
)
replyv
:=
_new
(
mtype
.
R
eplyType
)
err
=
codec
.
ReadRequestBody
(
argv
.
Interface
())
if
err
!=
nil
{
log
.
Println
(
"rpc: tearing down"
,
serviceMethod
[
0
],
"connection:"
,
err
)
...
...
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