Commit ad9bd85c authored by Jeff Lassahn's avatar Jeff Lassahn
Browse files

clear sent table when a reply is received so unexpected packets don't cause

random weirdness.
parent 7627da41
......@@ -259,20 +259,34 @@ func (h *HCI) send(c Command) ([]byte, error) {
h.close(fmt.Errorf("hci: failed to send whole cmd pkt to hci socket"))
var ret []byte
var err error
// emergency timeout to prevent calls from locking up if the HCI
// interface doesn't respond. Responsed here should normally be fast
// a timeout indicates a major problem with HCI.
timeout := time.NewTimer(10 * time.Second)
select {
case <-timeout.C:
return nil, fmt.Errorf("hci: no response to command, hci connection failed")
err = fmt.Errorf("hci: no response to command, hci connection failed")
ret = nil
case <-h.done:
return nil, h.err
err = h.err
ret = nil
case b := <-p.done:
return b, nil
err = nil
ret = b
// clear sent table when done, we sometimes get command complete or
// command status messages with no matching send, which can attempt to
// access stale packets in sent and fail or lock up.
delete(h.sent, c.OpCode())
return ret, err
func (h *HCI) sktLoop() {
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment