Backport from trunk (part of rev #9656)
- fixed deadlock in the TCP stack between TCP main process and a TCP worked (under heavy load).
  Credits for reporting it go to David Sanders
  Closes bug #3585606