Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
66228507
Commit
66228507
authored
Jun 25, 2015
by
Bas van Kervel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improved logging for IPC connection lifetime management
parent
5757a0ed
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
12 deletions
+23
-12
comms.go
rpc/comms/comms.go
+4
-4
ipc.go
rpc/comms/ipc.go
+5
-0
ipc_unix.go
rpc/comms/ipc_unix.go
+4
-1
ipc_windows.go
rpc/comms/ipc_windows.go
+10
-7
No files found.
rpc/comms/comms.go
View file @
66228507
...
@@ -43,7 +43,7 @@ type EthereumClient interface {
...
@@ -43,7 +43,7 @@ type EthereumClient interface {
SupportedModules
()
(
map
[
string
]
string
,
error
)
SupportedModules
()
(
map
[
string
]
string
,
error
)
}
}
func
handle
(
conn
net
.
Conn
,
api
shared
.
EthereumApi
,
c
codec
.
Codec
)
{
func
handle
(
id
int
,
conn
net
.
Conn
,
api
shared
.
EthereumApi
,
c
codec
.
Codec
)
{
codec
:=
c
.
New
(
conn
)
codec
:=
c
.
New
(
conn
)
for
{
for
{
...
@@ -52,8 +52,8 @@ func handle(conn net.Conn, api shared.EthereumApi, c codec.Codec) {
...
@@ -52,8 +52,8 @@ func handle(conn net.Conn, api shared.EthereumApi, c codec.Codec) {
codec
.
Close
()
codec
.
Close
()
return
return
}
else
if
err
!=
nil
{
}
else
if
err
!=
nil
{
glog
.
V
(
logger
.
Error
)
.
Infof
(
"comms recv err - %v
\n
"
,
err
)
codec
.
Close
()
codec
.
Close
()
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"Closed IPC Conn %06d recv err - %v
\n
"
,
id
,
err
)
return
return
}
}
...
@@ -71,8 +71,8 @@ func handle(conn net.Conn, api shared.EthereumApi, c codec.Codec) {
...
@@ -71,8 +71,8 @@ func handle(conn net.Conn, api shared.EthereumApi, c codec.Codec) {
err
=
codec
.
WriteResponse
(
responses
[
:
responseCount
])
err
=
codec
.
WriteResponse
(
responses
[
:
responseCount
])
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
V
(
logger
.
Error
)
.
Infof
(
"comms send err - %v
\n
"
,
err
)
codec
.
Close
()
codec
.
Close
()
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"Closed IPC Conn %06d send err - %v
\n
"
,
id
,
err
)
return
return
}
}
}
else
{
}
else
{
...
@@ -82,8 +82,8 @@ func handle(conn net.Conn, api shared.EthereumApi, c codec.Codec) {
...
@@ -82,8 +82,8 @@ func handle(conn net.Conn, api shared.EthereumApi, c codec.Codec) {
rpcResponse
=
shared
.
NewRpcResponse
(
requests
[
0
]
.
Id
,
requests
[
0
]
.
Jsonrpc
,
res
,
err
)
rpcResponse
=
shared
.
NewRpcResponse
(
requests
[
0
]
.
Id
,
requests
[
0
]
.
Jsonrpc
,
res
,
err
)
err
=
codec
.
WriteResponse
(
rpcResponse
)
err
=
codec
.
WriteResponse
(
rpcResponse
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
V
(
logger
.
Error
)
.
Infof
(
"comms send err - %v
\n
"
,
err
)
codec
.
Close
()
codec
.
Close
()
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"Closed IPC Conn %06d send err - %v
\n
"
,
id
,
err
)
return
return
}
}
}
}
...
...
rpc/comms/ipc.go
View file @
66228507
...
@@ -2,6 +2,7 @@ package comms
...
@@ -2,6 +2,7 @@ package comms
import
(
import
(
"fmt"
"fmt"
"math/rand"
"net"
"net"
"encoding/json"
"encoding/json"
...
@@ -95,3 +96,7 @@ func NewIpcClient(cfg IpcConfig, codec codec.Codec) (*ipcClient, error) {
...
@@ -95,3 +96,7 @@ func NewIpcClient(cfg IpcConfig, codec codec.Codec) (*ipcClient, error) {
func
StartIpc
(
cfg
IpcConfig
,
codec
codec
.
Codec
,
offeredApi
shared
.
EthereumApi
)
error
{
func
StartIpc
(
cfg
IpcConfig
,
codec
codec
.
Codec
,
offeredApi
shared
.
EthereumApi
)
error
{
return
startIpc
(
cfg
,
codec
,
offeredApi
)
return
startIpc
(
cfg
,
codec
,
offeredApi
)
}
}
func
newIpcConnId
()
int
{
return
rand
.
Int
()
%
1000000
}
rpc/comms/ipc_unix.go
View file @
66228507
...
@@ -48,7 +48,10 @@ func startIpc(cfg IpcConfig, codec codec.Codec, api shared.EthereumApi) error {
...
@@ -48,7 +48,10 @@ func startIpc(cfg IpcConfig, codec codec.Codec, api shared.EthereumApi) error {
continue
continue
}
}
go
handle
(
conn
,
api
,
codec
)
id
:=
newIpcConnId
()
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"New IPC connection with id %06d started
\n
"
,
id
)
go
handle
(
id
,
conn
,
api
,
codec
)
}
}
os
.
Remove
(
cfg
.
Endpoint
)
os
.
Remove
(
cfg
.
Endpoint
)
...
...
rpc/comms/ipc_windows.go
View file @
66228507
...
@@ -667,13 +667,16 @@ func startIpc(cfg IpcConfig, codec codec.Codec, api shared.EthereumApi) error {
...
@@ -667,13 +667,16 @@ func startIpc(cfg IpcConfig, codec codec.Codec, api shared.EthereumApi) error {
glog
.
V
(
logger
.
Error
)
.
Infof
(
"Error accepting ipc connection - %v
\n
"
,
err
)
glog
.
V
(
logger
.
Error
)
.
Infof
(
"Error accepting ipc connection - %v
\n
"
,
err
)
continue
continue
}
}
go
handle
(
conn
,
api
,
codec
)
id
:=
newIpcConnId
()
}
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"New IPC connection with id %06d started
\n
"
,
id
)
os
.
Remove
(
cfg
.
Endpoint
)
go
handle
(
id
,
conn
,
api
,
codec
)
}()
}
os
.
Remove
(
cfg
.
Endpoint
)
}()
glog
.
V
(
logger
.
Info
)
.
Infof
(
"IPC service started (%s)
\n
"
,
cfg
.
Endpoint
)
glog
.
V
(
logger
.
Info
)
.
Infof
(
"IPC service started (%s)
\n
"
,
cfg
.
Endpoint
)
return
nil
return
nil
...
...
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