• Gianluca Anzolin's avatar
    Bluetooth: Always wait for a connection on RFCOMM open() · 4a2fb3ec
    Gianluca Anzolin authored
    This patch fixes two regressions introduced with the recent rfcomm tty
    rework.
    
    The current code uses the carrier_raised() method to wait for the
    bluetooth connection when a process opens the tty.
    
    However processes may open the port with the O_NONBLOCK flag or set the
    CLOCAL termios flag: in these cases the open() syscall returns
    immediately without waiting for the bluetooth connection to
    complete.
    
    This behaviour confuses userspace which expects an established bluetooth
    connection.
    
    The patch restores the old behaviour by waiting for the connection in
    rfcomm_dev_activate() and removes carrier_raised() from the tty_port ops.
    
    As a side effect the new code also fixes the case in which the rfcomm
    tty device is created with the flag RFCOMM_REUSE_DLC: the old code
    didn't call device_move() and ModemManager skipped the detection
    probe. Now device_move() is always called inside rfcomm_dev_activate().
    Signed-off-by: default avatarGianluca Anzolin <gianluca@sottospazio.it>
    Reported-by: default avatarAndrey Vihrov <andrey.vihrov@gmail.com>
    Reported-by: default avatarBeson Chow <blc+bluez@mail.vanade.com>
    Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
    4a2fb3ec
tty.c 26.1 KB