• Johan Hedberg's avatar
    Bluetooth: Fix multiple LE socket handling · 44f3b0fb
    Johan Hedberg authored
    The LE ATT server socket needs to be superseded by any ATT client
    sockets. Previously this was done by looking at the hcon->out variable
    (indicating whether the connection is outgoing or incoming) which is a
    too crude way of determining whether the server socket needs to be
    picked or not (an outgoing connection doesn't necessarily mean that an
    ATT client socket has triggered it).
    
    This patch extends the ATT server socket lookup function
    (l2cap_le_conn_ready) to be used for all LE connections (regardless of
    the hcon->out value) and adds an internal check into the function for
    the existence of any ATT client sockets (in which case the server socket
    should be skipped). For this to work reliably all lookups must be done
    while the l2cap_conn->chan_lock is held, meaning also that the call to
    l2cap_chan_add needs to be changed to its lockless __l2cap_chan_add
    counterpart.
    Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
    Acked-by: default avatarMarcel Holtmann <marcel@holtmann.org>
    Signed-off-by: default avatarGustavo Padovan <gustavo.padovan@collabora.co.uk>
    44f3b0fb
l2cap_core.c 158 KB