cleanup mprpc, add netlink stub file
This commit is contained in:
parent
b1bebae325
commit
4eb31163a4
|
@ -56,7 +56,7 @@ import (
|
||||||
// ServiceFunc is a RPC service handler.
|
// ServiceFunc is a RPC service handler.
|
||||||
// It can be created manually, or by using the generic MakeService function on a
|
// It can be created manually, or by using the generic MakeService function on a
|
||||||
//
|
//
|
||||||
// func(msgp.Encoder) (msgp.Deocder, error)
|
// func(msgp.Encoder) (msgp.Decoder, error)
|
||||||
//
|
//
|
||||||
// type.
|
// type.
|
||||||
type ServiceFunc func(params msgp.Raw) (res msgp.Raw, err error)
|
type ServiceFunc func(params msgp.Raw) (res msgp.Raw, err error)
|
||||||
|
@ -152,7 +152,6 @@ func (rpc *RPCConn) Serve() {
|
||||||
case Response:
|
case Response:
|
||||||
cbCh, err := rpc.ct.Clear(rpcObject.MsgId)
|
cbCh, err := rpc.ct.Clear(rpcObject.MsgId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// TODO: scream
|
|
||||||
rpc.Logger.Warn("could not get rpc callback", "msgid", rpcObject.MsgId, "err", err)
|
rpc.Logger.Warn("could not get rpc callback", "msgid", rpcObject.MsgId, "err", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,13 +9,12 @@ import (
|
||||||
// RPCConntrack is a request-response tracker that is used to connect
|
// RPCConntrack is a request-response tracker that is used to connect
|
||||||
// the response to the appropriate caller.
|
// the response to the appropriate caller.
|
||||||
type rpcConnTrack struct {
|
type rpcConnTrack struct {
|
||||||
ct map[uint32]chan Response // TODO: change the values of the map for callbacks.
|
ct map[uint32]chan Response
|
||||||
mu sync.RWMutex
|
mu sync.RWMutex
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get attempts to get a random mark from the mutex.
|
// Get attempts to get a random mark from the mutex.
|
||||||
func (c *rpcConnTrack) Claim() (uint32, chan Response) {
|
func (c *rpcConnTrack) Claim() (uint32, chan Response) {
|
||||||
// TODO: make this threadsafe.
|
|
||||||
var val uint32
|
var val uint32
|
||||||
for {
|
for {
|
||||||
|
|
||||||
|
@ -50,7 +49,6 @@ func (c *rpcConnTrack) Claim() (uint32, chan Response) {
|
||||||
// associated with it. The caller can use the channel afterwards
|
// associated with it. The caller can use the channel afterwards
|
||||||
// to send the response.
|
// to send the response.
|
||||||
func (c *rpcConnTrack) Clear(val uint32) (chan Response, error) {
|
func (c *rpcConnTrack) Clear(val uint32) (chan Response, error) {
|
||||||
// TODO: get a lock
|
|
||||||
c.mu.RLock()
|
c.mu.RLock()
|
||||||
ch, ok := c.ct[val]
|
ch, ok := c.ct[val]
|
||||||
c.mu.RUnlock()
|
c.mu.RUnlock()
|
||||||
|
|
3
socketcan/netlink.go
Normal file
3
socketcan/netlink.go
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
package socketcan
|
||||||
|
|
||||||
|
// TODO: implement netlink support to set baud rate and other parameters.
|
Loading…
Reference in a new issue