From 4eb31163a4ab609b16be21907de1913bd77c03cf Mon Sep 17 00:00:00 2001 From: saji Date: Sun, 7 May 2023 00:00:46 -0500 Subject: [PATCH] cleanup mprpc, add netlink stub file --- mprpc/rpc.go | 3 +-- mprpc/rpcconntrack.go | 4 +--- socketcan/netlink.go | 3 +++ 3 files changed, 5 insertions(+), 5 deletions(-) create mode 100644 socketcan/netlink.go diff --git a/mprpc/rpc.go b/mprpc/rpc.go index 6165f20..543198f 100644 --- a/mprpc/rpc.go +++ b/mprpc/rpc.go @@ -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 } diff --git a/mprpc/rpcconntrack.go b/mprpc/rpcconntrack.go index e5f9fea..d18595b 100644 --- a/mprpc/rpcconntrack.go +++ b/mprpc/rpcconntrack.go @@ -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() diff --git a/socketcan/netlink.go b/socketcan/netlink.go new file mode 100644 index 0000000..8ff2796 --- /dev/null +++ b/socketcan/netlink.go @@ -0,0 +1,3 @@ +package socketcan + +// TODO: implement netlink support to set baud rate and other parameters.