Skip to content
Snippets Groups Projects
  • Deucе's avatar
    3bd80d0e
    Unlock ssh_mutex before calling sftps_recv() · 3bd80d0e
    Deucе authored
    This should fix the sftp hangs...
    While FreeBSD will return EDEADLOCK when a mutex would deadlock,
    Linux will do what I ask and deadlock.
    
    Since we're not checking the return value of pthread_mutex_lock(),
    this would go completely unnoticed on FreeBSD, resulting in the
    mutex being unlocked early and all sorts of unprotected accesses
    would happen, potentially doing crazy things.  On Linux it just
    deadlocks, and taking a peek at the thread backtraces makes the
    problem obvious.
    
    So, point to Linux for making life more correct for people who
    do incorrect things (locking without checking the return value).
    
    I'd also like to thank nelgin, for sticking with me on this issue
    and being my gdb puppet.
    
    And really, this commit should be shared by all the contributors
    who... 𝆺𝅥𝅮𝆺𝅥𝅮𝆹𝅥𝅯𝆹𝅥𝅯
    3bd80d0e
    History
    Unlock ssh_mutex before calling sftps_recv()
    Deucе authored
    This should fix the sftp hangs...
    While FreeBSD will return EDEADLOCK when a mutex would deadlock,
    Linux will do what I ask and deadlock.
    
    Since we're not checking the return value of pthread_mutex_lock(),
    this would go completely unnoticed on FreeBSD, resulting in the
    mutex being unlocked early and all sorts of unprotected accesses
    would happen, potentially doing crazy things.  On Linux it just
    deadlocks, and taking a peek at the thread backtraces makes the
    problem obvious.
    
    So, point to Linux for making life more correct for people who
    do incorrect things (locking without checking the return value).
    
    I'd also like to thank nelgin, for sticking with me on this issue
    and being my gdb puppet.
    
    And really, this commit should be shared by all the contributors
    who... 𝆺𝅥𝅮𝆺𝅥𝅮𝆹𝅥𝅯𝆹𝅥𝅯