cleanup mprpc, add netlink stub file

This commit is contained in:
saji 2023-05-07 00:00:46 -05:00
parent b1bebae325
commit 4eb31163a4
3 changed files with 5 additions and 5 deletions

View file

@ -56,7 +56,7 @@ import (
// ServiceFunc is a RPC service handler.
// 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 ServiceFunc func(params msgp.Raw) (res msgp.Raw, err error)
@ -152,7 +152,6 @@ func (rpc *RPCConn) Serve() {
case Response:
cbCh, err := rpc.ct.Clear(rpcObject.MsgId)
if err != nil {
// TODO: scream
rpc.Logger.Warn("could not get rpc callback", "msgid", rpcObject.MsgId, "err", err)
continue
}

View file

@ -9,13 +9,12 @@ import (
// RPCConntrack is a request-response tracker that is used to connect
// the response to the appropriate caller.
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
}
// Get attempts to get a random mark from the mutex.
func (c *rpcConnTrack) Claim() (uint32, chan Response) {
// TODO: make this threadsafe.
var val uint32
for {
@ -50,7 +49,6 @@ func (c *rpcConnTrack) Claim() (uint32, chan Response) {
// associated with it. The caller can use the channel afterwards
// to send the response.
func (c *rpcConnTrack) Clear(val uint32) (chan Response, error) {
// TODO: get a lock
c.mu.RLock()
ch, ok := c.ct[val]
c.mu.RUnlock()

3
socketcan/netlink.go Normal file
View file

@ -0,0 +1,3 @@
package socketcan
// TODO: implement netlink support to set baud rate and other parameters.