Fix a possible deadlock in TCP accepting

Each network thread holds an array of locks, indexed by a hash
of fd. When we accept a connection we hold a lock in accepting thread.
We then generate the thread number and lock bucket for the new
connection socket - if we hit the same thread and lock bucket as
accepting socket we get a deadlock. Avoid this by checking if we're
in the same thread/lock bucket and not locking in this case.
39 jobs for !1958 with 1046-deadlock-in-tcp-code in 10 minutes and 55 seconds (queued for 3 seconds)
detached
Status Job ID Name Coverage
  Precheck
passed #235884
amd64 linux
🐞:sid:amd64

00:00:12

passed #235883
amd64 linux
misc:sid:amd64

00:00:17

 
  Build
passed #235895
amd64 linux
asan:sid:amd64

00:02:50

passed #235896
amd64 linux
clang:stretch:amd64

00:01:46

passed #235897
i386 linux
clang:stretch:i386

00:01:50

passed #235885
amd64 linux
docs:sid:amd64

00:00:45

passed #235894
amd64 linux
gcc:bionic:amd64

00:01:38

passed #235886
amd64 linux
gcc:centos6:amd64

00:01:50

passed #235887
amd64 linux
gcc:centos7:amd64

00:01:59

passed #235892
amd64 linux
gcc:fedora29:amd64

00:02:34

passed #235888
amd64 linux
gcc:jessie:amd64

00:01:21

passed #235890
amd64 linux
gcc:sid:amd64

00:01:34

passed #235891
i386 linux
gcc:sid:i386

00:01:38

passed #235889
amd64 linux
gcc:stretch:amd64

00:01:42

passed #235893
amd64 linux
gcc:xenial:amd64

00:01:24

passed #235898
amd64 linux
pkcs11:sid:amd64

00:01:26

 
  Test
passed #235917
amd64 linux
system:asan:sid:amd64

00:07:47

passed #235915
amd64 linux
system:gcc:bionic:amd64

00:06:21

passed #235899
amd64 linux
system:gcc:centos6:amd64

00:06:25

passed #235901
amd64 linux
system:gcc:centos7:amd64

00:06:28

passed #235911
amd64 linux
system:gcc:fedora29:amd64

00:06:25

passed #235903
amd64 linux
system:gcc:jessie:amd64

00:06:34

passed #235907
amd64 linux
system:gcc:sid:amd64

00:06:56

passed #235909
i386 linux
system:gcc:sid:i386

00:06:27

passed #235905
amd64 linux
system:gcc:stretch:amd64

00:06:35

passed #235913
amd64 linux
system:gcc:xenial:amd64

00:06:45

passed #235920
amd64 linux
system:pkcs11:sid:amd64

00:06:41

passed #235918
amd64 linux
unit:asan:sid:amd64

00:01:11

passed #235919
amd64 linux
unit:clang:stretch:amd64

00:00:59

passed #235916
amd64 linux
unit:gcc:bionic:amd64

00:01:00

passed #235900
amd64 linux
unit:gcc:centos6:amd64

00:00:48

passed #235902
amd64 linux
unit:gcc:centos7:amd64

00:00:49

passed #235912
amd64 linux
unit:gcc:fedora29:amd64

00:01:04

passed #235904
amd64 linux
unit:gcc:jessie:amd64

00:00:30

passed #235908
amd64 linux
unit:gcc:sid:amd64

00:00:45

passed #235910
i386 linux
unit:gcc:sid:i386

00:00:59

passed #235906
amd64 linux
unit:gcc:stretch:amd64

00:01:00

passed #235914
amd64 linux
unit:gcc:xenial:amd64

00:01:04

passed #235921
amd64 linux
unit:pkcs11:sid:amd64

00:01:02